What 415 Unsupported Media Type means

415 Unsupported Media Type means the request body is in a format the server cannot or will not parse. Common cause: sending JSON to an endpoint that expects multipart/form-data, or vice versa. The response should include an Accept header listing the Content-Types the endpoint will accept (note: this is the unusual case where Accept appears on a response, not a request).

When servers should return it: Return 415 when the request Content-Type is not one the server accepts on this endpoint.

Common causes

  • POST JSON to a multipart-only endpoint
  • POST form-encoded to a JSON-only endpoint
  • Missing Content-Type header (server defaults to a type it does not accept)
  • Wrong charset (UTF-16 to a UTF-8-only endpoint)

How to fix 415 Unsupported Media Type

  • Set the correct Content-Type header: -H "Content-Type: application/json"
  • Curl with -d defaults to application/x-www-form-urlencoded; override with -H
  • Read the API docs for the exact expected Content-Type

Example response

curl -i -X POST -H "Content-Type: text/plain" -d "hello" https://api.example.com/users

HTTP/2 415
accept: application/json, multipart/form-data
content-type: application/json
{"error":"unsupported content-type"}

More references

For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.