4xx Client Error
HTTP 412 Precondition Failed
One or more conditions given in the request headers (like If-Match or If-Unmodified-Since) evaluated to false on the server. The conditional request cannot be fulfilled.
Common Causes
- If-Match ETag doesn't match current resource version
- If-Unmodified-Since date is older than last modification
- Optimistic concurrency check failed
- Conditional PUT/PATCH with stale data
How to Fix
- 1Fetch the latest resource version and update your ETag/date
- 2Re-read the resource before attempting the conditional update
- 3Remove precondition headers if strict versioning isn't needed
Example
HTTP 412 Precondition Failed
PUT /api/doc/1 HTTP/1.1 If-Match: "old-etag" → 412 Precondition Failed → Resource was modified by another client
Related Client Error Codes
400
Bad Request
401Unauthorized
402Payment Required
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable
407Proxy Authentication Required
408Request Timeout
409Conflict
410Gone
411Length Required
413Content Too Large
414URI Too Long
415Unsupported Media Type
416Range Not Satisfiable
417Expectation Failed
418I'm a Teapot
421Misdirected Request
422Unprocessable Content
423Locked
424Failed Dependency
425Too Early
426Upgrade Required
428Precondition Required
429Too Many Requests
431Request Header Fields Too Large
451Unavailable For Legal Reasons