A Basic Error Object
In the response below, the server is indicating that it encountered an error while creating/updating the resource, and that this error was caused by an invalid"first-name" attribute:HTTP/1.1 422 Unprocessable Entity
Content-Type: application/vnd.api+json
{
"errors": [
{
"status": "422",
"source": { "pointer": "/data/attributes/first-name" },
"title": "Invalid Attribute",
"detail": "First name must contain at least three characters."
}
]
}
The
source member is used to indicate
which part of the request document caused the error.The
title and detail members are similar, but detail is specific
to this occurrence of the problem, whereas title is more generic.The
status member represents the HTTP status code associated with the problem.
It’s very helpful when multiple errors are returned at once (see below), as the
HTTP response itself can only have one status code. However, it can also be
useful for single errors, to save clients the trouble of consulting the HTTP
headers, or for using JSON API over non-HTTP protocols, which may be officially
supported in the near future.
No comments:
Post a Comment