Bird
0
0

How should a REST API handle a request with multiple validation errors to return a 400 Bad Request?

hard📝 Application Q9 of 15
Rest API - HTTP Status Codes

How should a REST API handle a request with multiple validation errors to return a 400 Bad Request?

AReturn 500 Internal Server Error
BReturn only the first error found and ignore others
CReturn 200 OK with error details in the body
DReturn a list of all validation errors in the response body
Step-by-Step Solution
Solution:
  1. Step 1: Understand best practices for validation errors

    Returning all errors helps clients fix all issues at once.
  2. Step 2: Exclude incorrect approaches

    Ignoring errors or returning 200 or 500 is incorrect for validation failures.
  3. Final Answer:

    Return a list of all validation errors in the response body -> Option D
  4. Quick Check:

    List all errors in 400 response for better client feedback [OK]
Quick Trick: List all validation errors in 400 response body [OK]
Common Mistakes:
  • Returning only one error at a time
  • Using 200 OK for errors
  • Returning server error for client mistakes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes