Skip to content
Log In Sign Up info@muvcloud.com

What 415 Means

A request with a body (POST, PUT, PATCH) carries a Content-Type header that says what the body is: JSON, form data, XML, a file. The endpoint accepts only certain types. If the header names a type it does not handle, or is missing, the server answers 415 Unsupported Media Type before it reads the content.

The same code can also mean the server does not support the body's Content-Encoding, for example a compressed body the endpoint cannot unpack.

Common Causes

  • No Content-Type at all: the body is JSON, but nothing tells the server.
  • Form data where JSON is expected: curl's -d sends application/x-www-form-urlencoded unless you set the header.
  • JSON where form data or a file upload is expected: upload endpoints often want multipart/form-data.
  • A plain string body: some HTTP clients label a string body as text/plain.
  • A strict charset match: a few servers reject application/json; charset=utf-8 and accept only the bare type, or the other way round.
  • Compressed body: a Content-Encoding: gzip request to a server that does not decompress requests.

Fix It with curl

The request that often fails:

curl -i -X POST https://api.example.com/v1/items \
  -d '{"name":"Desk lamp"}'

The same request with the type declared:

curl -i -X POST https://api.example.com/v1/items \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"name":"Desk lamp"}'

curl 7.82.0 and later also have --json, which sets both headers and sends the data. For an upload endpoint, curl's -F option sends the body as multipart/form-data instead. More request examples are in curl POST request.

Read What the Server Accepts

Check the endpoint's documentation for the expected type. Some servers also add an Accept or Accept-Post header to the 415 response listing the types they take, or Accept-Encoding when the encoding was the problem; curl -i shows it. The body of the response often names the type that was refused.

415 Compared with 406

CodeAboutHeader involved
415What you sendContent-Type
406What you ask backAccept

A 406 means the server cannot answer in any format your Accept header allows; see 406 Not Acceptable. When the type is right but the data inside fails validation, the answer is 422 instead: see 422 Unprocessable Content.

Checks on the Server Side

  • Application log: the framework usually logs the content type it refused. The web server only passes the code through.
  • Route configuration: the endpoint may be declared to consume one type only; add the type you want to support.
  • A proxy that changes headers: a rule that removes or rewrites Content-Type on the way in causes 415 for every client.
  • A web application firewall: some rule sets block unusual content types before the application sees them.

From a Web Page

If a script on your own site gets 415 from your API, set the Content-Type header explicitly in the request and send the body as a JSON string. Check the request in the browser's developer tools, under the network panel, to see which type was actually sent.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations