Bird
Raised Fist0

How should an API handle error responses when a client sends a request with an unsupported media type?

hard🚀 Application Q9 of Q15
Rest API - Error Handling
How should an API handle error responses when a client sends a request with an unsupported media type?
AReturn HTTP status 415 with error JSON explaining unsupported media type
BReturn HTTP status 200 with error message in body
CReturn HTTP status 404 with empty body
DReturn HTTP status 500 with generic error message
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct HTTP status for unsupported media type

    415 Unsupported Media Type is the standard status for this error.
  2. Step 2: Confirm error response format

    Return JSON with error details explaining the issue.
  3. Final Answer:

    Return HTTP status 415 with error JSON explaining unsupported media type -> Option A
  4. Quick Check:

    Unsupported media type = 415 status with error JSON [OK]
Quick Trick: Use 415 status for unsupported media type errors [OK]
Common Mistakes:
MISTAKES
  • Returning 200 status on error
  • Using 404 or 500 incorrectly
  • Not providing error details in JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes