TLDR RFC 7807 Problem Details for HTTP APIs by E. Nottingham from Akamai
Standardized “problem detail” JSON HTTP response to avoid the need to define new error response formats for HTTP APIs.
Published in
1 min readNov 16, 2016
The data model for problem details is a JSON doc (“application/problem+json” media type). Also XML format is possible
An example:
HTTP/1.1 403 Forbidden
Content-Type: application/problem+json
Content-Language: en
{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/acc/12345/errors/out-of-credit/err_instance_id=123",
"balance": 30,
"account": "/acc/12345"
}
- A
type
URI with human-readable documentation for the problem type. This is the only required field. - A
title
that appropriately describes it (think short), SHOULD NOT change from occurrence to occurrence. - the HTTP status code for it to be used with.
- A
detail
string — with human-readable explanation specific to this
occurrence of the problem. - An
instance
string — a URI reference that identifies the specific
occurrence of the problem. - Response could be extended to clarify problem better. E.g.
balance
andaccount
fields in the example.
Problem details are intended to avoid the necessity of establishing new “fault” or “error” document formats, not to replace existing domain-specific formats.
For some of you guys it would be nice to hear that technology team from Zalando has in their Github working implementation of RFC 7807 and even with a Spring integration. Cheers to them!
Hit the 👏🏻 and share if you find it useful.
Thanks for reading.