devkult_
tools29converters34

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.

Class4xx Client Error
Retry?No — change the request first
Cacheable by defaultNo — only with explicit Cache-Control
Response bodyAllowed
Defined inRFC 9110 §15.5.16 — 415 Unsupported Media Type
Example response
HTTP/1.1 415 Unsupported Media Type
Content-Type: application/json
Content-Length: 34

{"error":"Unsupported Media Type"}

Common causes

  • No Content-Type on a JSON POST — fetch() labels string bodies text/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

  1. Set Content-Type: application/json when sending JSON.
  2. Use the encoding the API documents: JSON, multipart/form-data or x-www-form-urlencoded.
  3. On the server, list the supported types in an Accept or Accept-Post response header.

Send a 415 from your server

Express
res.status(415).json({ error: "Unsupported Media Type" });
Next.js route handler
return Response.json({ error: "Unsupported Media Type" }, { status: 415 });
Flask
return {"error": "Unsupported Media Type"}, 415
Go net/http
http.Error(w, "Unsupported Media Type", http.StatusUnsupportedMediaType)
nginx
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).

Headers used with 415
Related status codes