Bird
0
0

Identify the error in this REST API error response code snippet:

medium📝 Debug Q6 of 15
Rest API - Error Handling

Identify the error in this REST API error response code snippet:

return {"error": "Invalid input", "status": "400"}
AThe error message should be capitalized
BThe error key should be named message
CThe JSON keys are in the wrong order
DThe status code should be a number, not a string
Step-by-Step Solution
Solution:
  1. Step 1: Check data types of JSON values

    Status codes should be numeric, not strings, for machine processing.
  2. Step 2: Identify the incorrect type usage

    Here, "status" is given as a string "400" instead of number 400.
  3. Final Answer:

    The status code should be a number, not a string -> Option D
  4. Quick Check:

    Status code type must be number [OK]
Quick Trick: Status codes must be numbers, not strings [OK]
Common Mistakes:
  • Using string instead of number for status
  • Changing key names unnecessarily
  • Worrying about key order in JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes