Bird
0
0

Which of the following is the correct way to send a consistent error response in a REST API?

easy📝 Syntax Q12 of 15
Rest API - Error Handling
Which of the following is the correct way to send a consistent error response in a REST API?
AHTTP status 404 with a JSON body containing error code and message
BHTTP status 200 with error details in the body
CHTTP status 500 with no body
DHTTP status 302 redirecting to an error page
Step-by-Step Solution
Solution:
  1. Step 1: Identify proper HTTP status codes for errors

    404 means 'Not Found' and is appropriate for missing resources.
  2. Step 2: Check for clear error details in response body

    Including a JSON body with error code and message helps developers understand the issue.
  3. Final Answer:

    HTTP status 404 with a JSON body containing error code and message -> Option A
  4. Quick Check:

    Use correct status + clear JSON error [OK]
Quick Trick: Use proper HTTP status and JSON error body [OK]
Common Mistakes:
  • Using status 200 for errors
  • Sending no error details
  • Redirecting instead of error response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes