Bird
0
0

What will be the output HTTP status and JSON body if a REST API returns:

medium📝 Predict Output Q5 of 15
Rest API - Error Handling
What will be the output HTTP status and JSON body if a REST API returns:
{"error": {"code": 404, "message": "Resource not found"}}
?
AStatus 403 with JSON error message
BStatus 200 with JSON error message
CStatus 404 with JSON error message
DStatus 500 with empty body
Step-by-Step Solution
Solution:
  1. Step 1: Interpret the error code in JSON

    Code 404 means resource not found, so HTTP status should be 404.
  2. Step 2: Confirm response body matches error JSON

    The JSON body contains the error message, so it should be sent as is.
  3. Final Answer:

    Status 404 with JSON error message -> Option C
  4. Quick Check:

    404 error returns 404 status and error JSON [OK]
Quick Trick: Match HTTP status with error code and send JSON body [OK]
Common Mistakes:
  • Sending 200 status with error JSON
  • Returning empty body on error
  • Using wrong status code for resource not found

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes