0
0
Rest APIprogramming~20 mins

Problem Details (RFC 7807) format in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
RFC 7807 Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this RFC 7807 JSON example?

Given this JSON response following RFC 7807, what is the value of the title field?

Rest API
{
  "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"
}
AYour current balance is 30, but that costs 50.
Bhttps://example.com/probs/out-of-credit
C/account/12345/msgs/abc
DYou do not have enough credit.
Attempts:
2 left
💡 Hint

Look for the title key in the JSON object.

🧠 Conceptual
intermediate
1:30remaining
Which field in RFC 7807 is used to uniquely identify the specific occurrence of the problem?

In the Problem Details JSON format, which field uniquely identifies the specific occurrence of the problem?

Ainstance
Btitle
Ctype
Dstatus
Attempts:
2 left
💡 Hint

It is a URI reference that identifies the specific occurrence.

Predict Output
advanced
2:00remaining
What HTTP status code is represented in this RFC 7807 response?

Given this JSON snippet, what is the HTTP status code indicated?

Rest API
{
  "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"
}
A400
B422
C500
D404
Attempts:
2 left
💡 Hint

Check the status field in the JSON.

Predict Output
advanced
2:00remaining
What is the output of this Python code parsing an RFC 7807 response?

Consider this Python code that parses an RFC 7807 JSON response. What does it print?

Rest API
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'))
Ahttps://example.com/probs/out-of-credit
BYou do not have enough credit.
CYour current balance is 30, but that costs 50.
D/account/12345/msgs/abc
Attempts:
2 left
💡 Hint

Look at the key used in problem.get().

🧠 Conceptual
expert
2:30remaining
Which statement about the 'type' field in RFC 7807 is correct?

Choose the correct statement about the type field in the Problem Details (RFC 7807) format.

AIt is a URI that identifies the problem type and should always be dereferenceable to human-readable documentation.
BIt is a short human-readable summary of the problem type.
CIt is a URI reference that identifies the specific occurrence of the problem.
DIt is the HTTP status code associated with the problem.
Attempts:
2 left
💡 Hint

Think about the purpose of the type field as defined in RFC 7807.