0
0
Rest APIprogramming~20 mins

Nested error reporting in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nested Error Reporting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this nested error response JSON?
Given this nested error response from a REST API, what is the value of the message field inside the details object?
Rest API
{
  "error": {
    "code": 400,
    "message": "Validation Failed",
    "details": {
      "field": "email",
      "message": "Invalid email format"
    }
  }
}
A"Validation Failed"
B"Invalid email format"
C"email"
D400
Attempts:
2 left
💡 Hint
Look inside the nested 'details' object for the 'message' field.
Predict Output
intermediate
1:30remaining
What HTTP status code is returned in this nested error response?
Look at this nested error response JSON. What is the HTTP status code indicated by the status field inside the error object?
Rest API
{
  "error": {
    "status": 404,
    "message": "Resource not found",
    "details": {
      "resource": "user",
      "id": "123"
    }
  }
}
A404
B"Resource not found"
C123
D"user"
Attempts:
2 left
💡 Hint
The status code is usually a number inside the 'error' object.
🔧 Debug
advanced
2:00remaining
Which option causes a JSON parsing error?
One of these nested error response JSON strings is invalid and will cause a parsing error. Which one?
A{ "error": { "code": 403, "message": "Forbidden", "details": { "action": "Access denied" } } }
B{ "error": { "code": 500, "message": "Server error", "details": { "info": "Unexpected failure" } } }
C{ "error": { "code": 400, "message": "Bad request", "details": { "field": "name", "message": "Missing value" } }
D{ "error": { "code": 401, "message": "Unauthorized", "details": { "reason": "Token expired" } } }
Attempts:
2 left
💡 Hint
Look for missing or extra brackets in the JSON strings.
🧠 Conceptual
advanced
1:30remaining
What is the main benefit of nesting error details in REST API responses?
Why do REST APIs often nest detailed error information inside an 'error' object rather than placing all fields at the top level?
ATo reduce the size of the response by nesting fields
BTo confuse the client and make debugging harder
CTo make the response invalid JSON intentionally
DTo organize error information clearly and separate it from other response data
Attempts:
2 left
💡 Hint
Think about clarity and structure in data.
Predict Output
expert
2:00remaining
What is the value of 'error.details.errors[1].message' in this nested error response?
Given this nested error response JSON, what is the value of the second error message inside the 'errors' list?
Rest API
{
  "error": {
    "code": 422,
    "message": "Validation Error",
    "details": {
      "errors": [
        {"field": "username", "message": "Required field"},
        {"field": "password", "message": "Too short"},
        {"field": "email", "message": "Invalid format"}
      ]
    }
  }
}
A"Too short"
B"Invalid format"
C"Required field"
D"Validation Error"
Attempts:
2 left
💡 Hint
Remember that list indexes start at 0.