Bird
0
0

Which of the following is a correct JSON structure for a simple error response in a REST API?

easy📝 Syntax Q12 of 15
Rest API - Request and Response Format
Which of the following is a correct JSON structure for a simple error response in a REST API?
A{"error": {"code": 404, "message": "Not Found"}}
B{"status": 200, "message": "Success"}
C{"data": {"id": 1, "name": "Item"}}
D{"error_code": "404", "error_msg": "Not Found"}
Step-by-Step Solution
Solution:
  1. Step 1: Identify standard error response keys

    Common keys include "error", "code", and "message" to describe the problem.
  2. Step 2: Check each option

    {"error": {"code": 404, "message": "Not Found"}} uses "error" with "code" and "message" correctly in JSON format.
  3. Final Answer:

    {"error": {"code": 404, "message": "Not Found"}} -> Option A
  4. Quick Check:

    Standard error keys = code and message [OK]
Quick Trick: Look for 'error', 'code', and 'message' keys in JSON [OK]
Common Mistakes:
MISTAKES
  • Confusing success response with error
  • Using wrong key names like error_code
  • Missing nested error object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes