1

What is the most correct/meaningful HTTP status code to return when your web server cannot handles the incoming request because it does not understands what the Content-Type of the incoming request body is?

Returning straight 400 seems like a bad idea since, according to Wikipedia:

e.g., malformed request syntax, invalid request message framing, or deceptive request routing

And we actually returns 400 when there are parsing errors or similar things for some content types like application/json or some of the XML variants.

So is there an HTTP status code to indicate that we don't know how to process the request besides HTTP 400?

chakrit
  • 57,172
  • 24
  • 125
  • 160
  • possible duplicate of [HTTP status code for unaccepted Content-Type in request](http://stackoverflow.com/questions/11973813/http-status-code-for-unaccepted-content-type-in-request) and [Appropriate HTTP status code for request specifying invalid Content-Encoding header?](http://stackoverflow.com/questions/11461037/appropriate-http-status-code-for-request-specifying-invalid-content-encoding-hea) – Matt Ball Mar 07 '15 at 18:48

1 Answers1

3

HTTP 415 Unsupported Media Type is the status code you're looking for.

The request entity has a media type which the server or resource does not support. For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.

From the RFC:

The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

Matt Ball
  • 332,322
  • 92
  • 617
  • 683