Bird
0
0

You want to design an error response format that includes an error code, a message, and optional details for debugging. Which JSON structure below best fits this need?

hard📝 Application Q15 of 15
Rest API - Request and Response Format
You want to design an error response format that includes an error code, a message, and optional details for debugging. Which JSON structure below best fits this need?
A{"error": "Bad Request", "code": 400}
B{"status": "error", "code": 400, "msg": "Bad Request"}
C{"error_code": 400, "error_message": "Bad Request"}
D{"error": {"code": 400, "message": "Bad Request", "details": "Missing 'id' parameter"}}
Step-by-Step Solution
Solution:
  1. Step 1: Check required fields in each option

    We need code, message, and optional details inside a clear error object.
  2. Step 2: Evaluate each JSON structure

    {"error": {"code": 400, "message": "Bad Request", "details": "Missing 'id' parameter"}} includes all three: code, message, and details nested inside "error".
  3. Final Answer:

    {"error": {"code": 400, "message": "Bad Request", "details": "Missing 'id' parameter"}} -> Option D
  4. Quick Check:

    Include code, message, and details in error object [OK]
Quick Trick: Include optional details inside error object for clarity [OK]
Common Mistakes:
  • Omitting details field
  • Using inconsistent key names
  • Not nesting error info properly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes