415 Unsupported Media Type
4xx client error
The server won't accept the format of the request body (its Content-Type).
415 is about what you sent, not what you want back: the request's Content-Type (or Content-Encoding) isn't one the endpoint accepts. The most common case is posting JSON without Content-Type: application/json, so the server reads the body as plain text or form data.
| Class | 4xx Client Error |
|---|---|
| Retry? | No — change the request first |
| Cacheable by default | No — only with explicit Cache-Control |
| Response body | Allowed |
| Defined in | RFC 9110 §15.5.16 — 415 Unsupported Media Type |
HTTP/1.1 415 Unsupported Media Type
Content-Type: application/json
Content-Length: 34
{"error":"Unsupported Media Type"}Common causes
- No
Content-Typeon a JSON POST —fetch()labels string bodiestext/plain. - Sending form-urlencoded data to a JSON-only endpoint, or the reverse.
- Uploading a file type the endpoint rejects.
- A compressed body (
Content-Encoding: gzip) the server can't decode.
How to fix it
- Set
Content-Type: application/jsonwhen sending JSON. - Use the encoding the API documents: JSON,
multipart/form-dataorx-www-form-urlencoded. - On the server, list the supported types in an
AcceptorAccept-Postresponse header.
Send a 415 from your server
res.status(415).json({ error: "Unsupported Media Type" });return Response.json({ error: "Unsupported Media Type" }, { status: 415 });return {"error": "Unsupported Media Type"}, 415http.Error(w, "Unsupported Media Type", http.StatusUnsupportedMediaType)
return 415;
Check what a URL returns
Print just the status line from the command line, or check a whole list of URLs at once, with their response headers, in the HTTP Status Checker.
curl -sI https://example.com/your-path | head -n 1
Frequently asked questions
Why does fetch() get 415 with a JSON body?
fetch(url, { method: 'POST', body: JSON.stringify(data) }) sends Content-Type: text/plain;charset=UTF-8. Add headers: { 'Content-Type': 'application/json' }.
415 vs 406?
415: the server can't accept the format you sent (Content-Type). 406: the server can't produce a format you'll accept (Accept).