428 Precondition Required
The 428 HTTP response status code means that certain requests must include preconditions to be fulfilled, but the client failed to include them in the request.
You can Check Your URLs HTTP Code for FREE
Introduction
In Action
Sample
Conclusion
Introduction
When the server returns the HTTP response status code 428 Precondition Required, it means that certain requests must include preconditions to be fulfilled, but the client failed to include them in the request.
Precondition headers are essential for certain operations, ensuring that the request is processed only if specific conditions are met. Without these preconditions, the server refuses to proceed with the request to maintain data integrity and safety.
In Action
When the server returns the HTTP response status code 428 Precondition Required, it means that the client must include specific headers like If-Match, If-None-Match, If-Modified-Since, or If-Unmodified-Since in the request.
These headers help prevent data loss issues, like the ‘lost update’ problem, where a client unintentionally overwrites changes made by other parties. By using these headers, clients can check the current state of the resource on the server before making updates, reducing conflicts and ensuring data integrity.
This status code is related to 412 Precondition Failed, which is returned when the specified conditions are not met.
Sample
In the example, the client received a resource from the server earlier, and now it wants to update it by sending a modified version using the PUT method. However, the server sends back the 428 Precondition Required status because the client didn’t include the necessary conditional headers in the request.
These headers are essential to ensure that the client’s changes don’t accidentally overwrite any updates made by others, preventing data conflicts and maintaining data integrity.
Request
PUT /reservations.txt HTTP/1.1
Host: www.example.com
Response
HTTP/1.1 428 Precondition Required
Content-Type: text/html
Content-Length: 193
< html>
< head>
< title>Conditional Update Required< /title>
< /head>
< body>
< p>This PUT request must be done conditionally. Try again using “If-Unmodified-Since”.< /p>
< /body>
< /html>
Conclusion
The 428 Precondition Required status code indicates that when making certain HTTP requests, the client must include specific conditional headers like If-Match, If-None-Match, If-Modified-Since, or If-Unmodified-Since.
These headers are necessary to prevent data conflicts and maintain data integrity by ensuring that the client’s actions are consistent with the current state of the resource on the server.