I’m looking for an example for a 404 response when an object is not found, and in the case of a partial response.
Standard 404 response
If one does:
GET /articles/123 HTTP/1.1
But 123 does not exist, I’m expecting the error response should look like this (according to the specification here http://jsonapi.org/format/#error-objects):
{
"errors": [
{
"id": "1",
"status": 404,
"code": "not-found",
"title": "Article Not Found",
"detail": "Article 123 is not available on this server"
}
]
}
My question is - is that acceptable?
source and pointer
My second question is where does “source” and corresponding “pointer” go in a response like this?
Partial Responses
My final question is on partial responses…
Example:
GET /articles?filter[id]=1,2,3,4,555,777,999 HTTP/1.1
-
HTTP status code? If several resources are found but one or more are not found, what HTTP status code should be used? 206 seems appropriate by name, but the actual specification seems to indicate that 206 is only appropriate for HTTP Range requests, unless I’m mis-reading or mis-understanding things (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
-
format: Should error objects just be added to the top-level json for each item that’s not found? I think that’s logical, but I just wanted to double check.
Example:
{
"data": { ... }
"errors": {
[
{
"id": 1,
"status": 404,
"code": "not-found",
"source": { ... }
},
{
"id": 2,
"status": 404,
"code": "not-found",
"source": { ... }
},
]
}
I’m presuming, but maybe I’m wrong, but the pointer to the element that wasn’t found would be in “source”? correct?