Content-Type / Accept header error responses

Hi there!

I’m having a hard time interpreting the following Server Responsibilities:

Servers MUST respond with a 415 Unsupported Media Type status code if a request specifies the header Content-Type: application/vnd.api+json with any media type parameters.

Does the above mean that a 415 HTTP status response must be sent only when the content type is application/vnd.api+json and media type parameters are included? What if a client sends application/json or something else? What if the client doesn’t send the header?

Servers MUST respond with a 406 Not Acceptable status code if a request’s Accept header contains the JSON:API media type and all instances of that media type are modified with media type parameters.

And given the Accept header also needs to be checked (if present), does it mean a client can send one or the other, or both?

Currently, my interpretation is as follows:

  • A client can send Content-Type, Accept, both or no headers.
  • If any of those headers is passed and the value is exactly application/vnd.api+json or anything else (as long as it doesn’t have application/vnd.api+json with media type parameters), it’s fine.
  • Otherwise send a 415 or 406.

Is this correct?

1 Like

@dgeb, @ethanresnick, can you shed some light?