HTTP 412 Precondition Failed vs 415 Unsupported Media Type
Both HTTP 412 (Precondition Failed) and 415 (Unsupported Media Type) belong to the 4xx Client Error category. 412 indicates that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false. Meanwhile, 415 means that the server refuses to accept the request because the Content-Type is not supported.
Description
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
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 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
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 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending.