Bird
0
0

Given this error response JSON:

medium📝 Predict Output Q13 of 15
Rest API - Request and Response Format
Given this error response JSON:
{"error": {"code": 401, "message": "Unauthorized"}}

What HTTP status code should the API return?
A401
B500
C404
D200
Step-by-Step Solution
Solution:
  1. Step 1: Match error code to HTTP status

    The error code 401 means "Unauthorized", which is an HTTP status code for authentication failure.
  2. Step 2: Confirm correct HTTP status

    The API should return HTTP status 401 to match the error code in the response body.
  3. Final Answer:

    401 -> Option A
  4. Quick Check:

    Error code 401 = HTTP status 401 [OK]
Quick Trick: Match error code with HTTP status code [OK]
Common Mistakes:
  • Returning 200 for error responses
  • Confusing 401 with 404
  • Using 500 for client errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes