415 Unsupported Media Type: what it means and what to do

A 415 means the server will not accept the format of what was sent. The official definition in RFC 9110 is that the origin server refuses to accept the request because the payload format is in a media type the target resource does not support. The request is labeled by its Content-Type header, and a 415 is the server saying that label names something it cannot or will not handle, such as JSON sent to an endpoint that only accepts form data, or an image format an upload page does not allow.

If you are just visiting a site

  1. Convert the file to an accepted format. Upload forms that reject a file with a 415 (or a format error) usually list what they take: JPG and PNG for images, PDF for documents. Converting the file is the fix.
  2. Do not just rename the extension. Servers check the actual content and its declared type, not only the filename. A renamed file usually earns the same rejection.
  3. Try the service's app or another upload path. Different upload paths sometimes accept different formats, especially for media.

If it is your site or your API

  1. Compare Content-Type with what you parse. The classic 415 is a client posting application/json while the endpoint only binds form data, or the reverse. Your logs show both sides of the mismatch.
  2. Watch for a missing Content-Type entirely. Some frameworks answer 415 when the header is absent because they cannot select a parser. Decide whether that strictness is intentional.
  3. Charset counts too. A declared charset your parser does not support can produce a 415 on otherwise fine data.
  4. Name the accepted types in the response. Listing what you do accept turns the error into documentation.
Visitors: convert the file to a listed format, renaming alone will not work. Developers: the Content-Type header in the failing request and the parsers on your route are the only two facts you need.

Common questions

What is the difference between 406 and 415? They face opposite directions. A 415 is about the format of the request the client sent. A 406 is about the format of the response the client asked for. One rejects what came in, the other cannot produce what was requested back.

Why does an API return 415 for a JSON post? Usually because the endpoint was never configured to parse JSON, or the client sent the data without the Content-Type: application/json header, so the framework could not tell what it was looking at and refused it.

Related errors

406 Not Acceptable · 400 Bad Request · 422 Unprocessable Content