Given this JSON response following RFC 7807, what is the value of the title field?
{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"status": 403,
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/account/12345/msgs/abc"
}Look for the title key in the JSON object.
The title field in RFC 7807 provides a short, human-readable summary of the problem type. Here, it is "You do not have enough credit."
In the Problem Details JSON format, which field uniquely identifies the specific occurrence of the problem?
It is a URI reference that identifies the specific occurrence.
The instance field is a URI reference that identifies the specific occurrence of the problem, allowing clients to distinguish between different occurrences.
Given this JSON snippet, what is the HTTP status code indicated?
{
"type": "https://example.com/probs/invalid-input",
"title": "Invalid input provided.",
"status": 422,
"detail": "The 'email' field must be a valid email address.",
"instance": "/users/abc123"
}Check the status field in the JSON.
The status field indicates the HTTP status code. Here it is 422, which means Unprocessable Entity.
Consider this Python code that parses an RFC 7807 JSON response. What does it print?
import json response = '''{ "type": "https://example.com/probs/out-of-credit", "title": "You do not have enough credit.", "status": 403, "detail": "Your current balance is 30, but that costs 50.", "instance": "/account/12345/msgs/abc" }''' problem = json.loads(response) print(problem.get('detail'))
Look at the key used in problem.get().
The code prints the value of the detail key, which is "Your current balance is 30, but that costs 50."
Choose the correct statement about the type field in the Problem Details (RFC 7807) format.
Think about the purpose of the type field as defined in RFC 7807.
The type field is a URI that identifies the problem type. It is recommended to be dereferenceable to human-readable documentation, but it is not mandatory. It helps clients understand the kind of problem.