HTTP 411 Length Required vs 428 Precondition Required
Both HTTP 411 (Length Required) and 428 (Precondition Required) belong to the 4xx Client Error category. 411 indicates that the server refuses to accept the request without a Content-Length header. Meanwhile, 428 means that the server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
Description
The server refuses to accept the request without a Content-Length header.
When You See It
When sending a request body without specifying Content-Length.
How to Fix
Include a Content-Length header in your request.
Description
The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
When You See It
When an API requires optimistic concurrency control via ETags.
How to Fix
Fetch the resource first to get its ETag, then include If-Match in your update request.
Key Differences
HTTP 411: The server refuses to accept the request without a Content-Length header.
HTTP 428: The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.
You encounter 411 when when sending a request body without specifying Content-Length.
You encounter 428 when when an API requires optimistic concurrency control via ETags.
When to Use Which
For 411 (Length Required): Include a Content-Length header in your request. For 428 (Precondition Required): Fetch the resource first to get its ETag, then include If-Match in your update request.