Bird
Raised Fist0

You receive this Problem Details JSON response:

medium📝 Predict Output Q4 of Q15
Rest API - Error Handling
You receive this Problem Details JSON response:
{"type": "https://example.com/probs/forbidden-action", "title": "Action Forbidden", "status": 403, "detail": "You are not allowed to perform this action."}

What HTTP status code should the server return along with this response?
A404
B400
C403
D500
Step-by-Step Solution
Solution:
  1. Step 1: Identify the status field value

    The JSON response includes "status": 403, which indicates the HTTP status code to be used.
  2. Step 2: Understand the meaning of status 403

    Status code 403 means "Forbidden", indicating the client is authenticated but not authorized to perform the action.
  3. Final Answer:

    403 -> Option C
  4. Quick Check:

    Status code matches the "status" field in the Problem Details response [OK]
Quick Trick: Use the 'status' field value as the HTTP status code [OK]
Common Mistakes:
MISTAKES
  • Returning 400 instead of 403
  • Ignoring the 'status' field and returning 200
  • Confusing 403 with 404 Not Found

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes