HTTP 400 Bad Request vs 415 Unsupported Media Type
Both HTTP 400 (Bad Request) and 415 (Unsupported Media Type) belong to the 4xx Client Error category. 400 indicates that the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing. Meanwhile, 415 means that the server refuses to accept the request because the Content-Type is not supported.
Description
The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
When You See It
When sending malformed JSON, missing required fields, or invalid query parameters.
How to Fix
Check the request body format, validate all required fields, and ensure proper encoding.
Description
The server refuses to accept the request because the Content-Type is not supported.
When You See It
When sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
How to Fix
Set the correct Content-Type header matching the data format you're sending.
Key Differences
HTTP 400: The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
You encounter 400 when when sending malformed JSON, missing required fields, or invalid query parameters.
You encounter 415 when when sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
When to Use Which
For 400 (Bad Request): Check the request body format, validate all required fields, and ensure proper encoding. For 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending.