Bird
0
0

Which of the following is the correct JSON structure for a human-readable error message in a REST API?

easy📝 Syntax Q3 of 15
Rest API - Error Handling

Which of the following is the correct JSON structure for a human-readable error message in a REST API?

A{"error": "Invalid input", "code": 400}
B["Invalid input", 400]
C"Invalid input"
D{"message": 400, "error": "Invalid input"}
Step-by-Step Solution
Solution:
  1. Step 1: Identify proper JSON key-value pairs

    Human-readable errors usually have keys like "error" or "message" with string values describing the problem.
  2. Step 2: Check for correct data types and structure

    {"error": "Invalid input", "code": 400} uses a JSON object with descriptive keys and appropriate values.
  3. Final Answer:

    {"error": "Invalid input", "code": 400} -> Option A
  4. Quick Check:

    Correct JSON error format = Object with keys [OK]
Quick Trick: Use key-value pairs in JSON for errors [OK]
Common Mistakes:
  • Using arrays instead of objects
  • Putting status code as string
  • Using wrong key names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes