HTTP 412 Precondition Failed vs 414 URI Too Long
Both HTTP 412 (Precondition Failed) and 414 (URI Too Long) 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, 414 means that the URI provided was too long for the server to process.
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 URI provided was too long for the server to process.
When You See It
When query strings are extremely long or when accidentally sending a request body in the URL.
How to Fix
Shorten the URL. Move long parameters to the request body using POST instead of GET.
Key Differences
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
HTTP 414: The URI provided was too long for the server to process.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
You encounter 414 when when query strings are extremely long or when accidentally sending a request body in the URL.
When to Use Which
For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 414 (URI Too Long): Shorten the URL. Move long parameters to the request body using POST instead of GET.