3 ms·
There is a draft RFC for returning errors in APIs based on JSON. http://datatracker.ietf.org/doc/draft-ietf-appsawg-http-problem/?include_text=1 http://datatra
by pmontra 12y ago
There is a draft RFC for returning errors in APIs based on JSON.
http://datatracker.ietf.org/doc/draft-ietf-appsawg-http-problem/?include_text=1 http://datatracker.ietf.org/doc/draft-ietf-appsawg-http-prob...
Their example:
HTTP/1.1 403 Forbidden
Content-Type: application/problem+json
Content-Language: en
{
"type": "http://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "http://example.net/account/12345/msgs/abc",
"balance": 30,
"accounts": ["http://example.net/account/12345",
"http://example.net/account/67890"]
}
type, title, detail and instance are attributes defined by the spec. balance and accounts are extra attributes added for this error. I suppose that if I want to return validation errors to decorate an input form I'll have to add many custom attributes like those.