Bird
0
0

Identify the error in this nested error JSON response:

medium📝 Debug Q14 of 15
Rest API - Error Handling

Identify the error in this nested error JSON response:

{
  "error": {
    "message": "Invalid data",
    "details": [
      { "field": "username", "error": "Required" },
      { "field": "age", "error": 25 }
    ]
  }
}
AThe 'error' value for 'age' should be a string, not a number
BThe 'details' key should be a string, not an array
CThe 'message' key is missing
DThe 'field' keys should be numbers
Step-by-Step Solution
Solution:
  1. Step 1: Check error value types in details array

    Each error value should be a descriptive string, not a number.
  2. Step 2: Identify incorrect error value

    The 'age' field has error value 25 (number), which is incorrect.
  3. Final Answer:

    The 'error' value for 'age' should be a string, not a number -> Option A
  4. Quick Check:

    Error values must be strings [OK]
Quick Trick: Error messages must be strings, not numbers [OK]
Common Mistakes:
  • Ignoring type mismatch in error values
  • Thinking details must be string instead of array
  • Missing the message key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes