To include content (or not) in HTTP 404 responses?


#1

Should HTTP 404 responses include content (i.e., a JSON document)? Would it go against the spec to omit content in the response, meaning no response body?

The [spec says](http://http://jsonapi.org/format/…

A JSON object MUST be at the root of every JSON API request and response containing data.

The key word I see there is “containing data”. An HTTP 404 status code itself already communicates everything that needs to be known about the error. As the HTTP 1.1 specs says about the 404 code:

The server has not found anything matching the Request-URI. No
indication is given of whether the condition is temporary or
permanent. … This status code is commonly used when the server does not wish to
reveal exactly why the request has been refused, or when no other
response is applicable.

I’m not seeing any value right now in actually returning content with an HTTP 404 response, but I’d love to get others thoughts on the matter.


#2

404 Not Found is an error response, so you can include content as described in the section Errors.