Bird
0
0

An API returns this error response:

medium📝 Debug Q7 of 15
Rest API - Error Handling
An API returns this error response:
{"error": {"code": 500, "message": "Server error"}}

But the client receives HTTP status 200. What is the problem?
AThe server should send HTTP status 500, not 200
BThe error message is incorrect
CThe error code should be 200
DThe JSON format is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Match HTTP status with error code

    HTTP status must reflect the error code; 500 means server error, so status should be 500.
  2. Step 2: Identify mismatch issue

    Sending 200 status with error JSON confuses clients about success.
  3. Final Answer:

    The server should send HTTP status 500, not 200 -> Option A
  4. Quick Check:

    HTTP status must match error code [OK]
Quick Trick: Always align HTTP status with error code in response [OK]
Common Mistakes:
  • Sending 200 status with error JSON
  • Ignoring HTTP status code importance
  • Assuming error message fixes status mismatch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes