Bird
0
0

Which JSON structure best represents a REST API error response that includes a machine-readable error code, a human-readable message, and a timestamp?

hard📝 Application Q8 of 15
Rest API - Error Handling

Which JSON structure best represents a REST API error response that includes a machine-readable error code, a human-readable message, and a timestamp?

A{ "code": "ERR123", "message": "Invalid input", "timestamp": "2024-06-01T12:00:00Z" }
B{ "error": "Invalid input", "status": 400, "time": "12:00" }
C{ "status": 400, "error": "ERR123", "date": "2024-06-01" }
D{ "message": "ERR123", "code": 400, "timestamp": "now" }
Step-by-Step Solution
Solution:
  1. Step 1: Identify required fields

    Must have a machine-readable code, human message, and ISO timestamp.
  2. Step 2: Evaluate options

    { "code": "ERR123", "message": "Invalid input", "timestamp": "2024-06-01T12:00:00Z" } uses 'code' for machine code, 'message' for human text, and ISO 8601 timestamp format.
  3. Step 3: Reject others

    Others mix fields incorrectly or use ambiguous keys and formats.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Clear keys and ISO timestamp [OK]
Quick Trick: Use clear keys and ISO timestamps [OK]
Common Mistakes:
  • Using ambiguous or inconsistent key names
  • Not using ISO 8601 format for timestamps
  • Mixing error code and message fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes