Bird
Raised Fist0

You receive this error response from your API:

medium📝 Debug Q14 of Q15
Rest API - Error Handling
You receive this error response from your API:
{"error": {"code": "400", "message": "Bad Request"}}

Why might this cause problems in your client code expecting code as a number?
ABecause the error key is misspelled
BBecause the message is missing
CBecause the code is a string, not a number, causing type errors
DBecause the JSON is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Identify the data type of code field

    The code field is given as a string "400" instead of a number 400.
  2. Step 2: Understand client expectations

    If client expects a number, receiving a string can cause type errors or failed comparisons.
  3. Final Answer:

    Because the code is a string, not a number, causing type errors -> Option C
  4. Quick Check:

    Type mismatch in code field causes errors [OK]
Quick Trick: Check if code is number, not string, to avoid type errors [OK]
Common Mistakes:
MISTAKES
  • Ignoring type differences
  • Assuming message is missing
  • Thinking JSON is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes