HTTP 412 Precondition Failed vs 417 Expectation Failed
Both HTTP 412 (Precondition Failed) and 417 (Expectation Failed) 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, 417 means that the server cannot meet the requirements of the Expect header.
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 cannot meet the requirements of the Expect header.
When You See It
When the server doesn't support Expect: 100-continue.
How to Fix
Remove the Expect header from your request.
Key Differences
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
HTTP 417: The server cannot meet the requirements of the Expect header.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
You encounter 417 when when the server doesn't support Expect: 100-continue.
When to Use Which
For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 417 (Expectation Failed): Remove the Expect header from your request.