{"id":16127,"date":"2025-07-24T18:12:13","date_gmt":"2025-07-24T16:12:13","guid":{"rendered":"https:\/\/surver.nl\/?post_type=kennisbank&#038;p=16127"},"modified":"2025-08-21T12:39:13","modified_gmt":"2025-08-21T10:39:13","slug":"status-code-412","status":"publish","type":"kennisbank","link":"https:\/\/surver.nl\/en\/kennisbank\/statuscode-412\/","title":{"rendered":"What does status code 412 Precondition Failed mean?"},"content":{"rendered":"<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1.png\" alt=\"\" class=\"wp-image-16372\" srcset=\"https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1.png 1024w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1-300x300.png 300w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1-150x150.png 150w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1-768x768.png 768w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/f0186486-8e4d-4700-994b-215ee9b63421-1-12x12.png 12w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Some HTTP errors are clear. A 404 means something doesn't exist. A 403 says you're not allowed to access something. But a 412 status code? That one is less common, and therefore raises all the more questions.<\/p>\n\n\n\n<p>Yet technically it is a logical error message. Not a broken URL, not a syntax error. Just: a condition that is wrong. Or rather: a condition that you, the client, set, but that the server does not agree with.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What exactly does a 412 do?<\/h2>\n\n\n\n<p>The 412 Precondition Failed error occurs when you make a request with a certain precondition, and that precondition turns out to be no longer valid.<\/p>\n\n\n\n<p>It often involves headers like If-Match or If-Unmodified-Since. With these, you are basically saying, \"I only want to perform this update if the version of the file is still exactly as it was when I last retrieved it.\"<\/p>\n\n\n\n<p>If that state has since changed, because another system or user has already modified the file, the server breaks the transaction. And returns: 412.<\/p>\n\n\n\n<p>You asked something, but with an insert. And the server says: that's not right anymore. We're not going to do it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When do you encounter this error?<\/h2>\n\n\n\n<p>Almost always in APIs or applications where versions or synchronization are involved. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A frontend trying to update a document via a PUT request, with ETag.<\/li>\n\n\n\n<li>An integration that uses version control via headers.<\/li>\n\n\n\n<li>A client trying to modify an object that has already been modified in the meantime.<\/li>\n<\/ul>\n\n\n\n<p>In such situations, you don't want an obsolete version to just overwrite anything. And so preconditions are used as a control mechanism.<\/p>\n\n\n\n<p>You don't easily see a 412 status code in the browser. But tools like curl, Postman or your server logs will display it clearly.<\/p>\n\n\n\n<p>Example with curl:<\/p>\n\n\n\n<p><strong><em>curl -X PUT https:\/\/api.site.nl\/item\/42 -H 'If-Match: \"v3.4.1\u2033'<\/em><\/strong><\/p>\n\n\n\n<p>If that version has since become v3.4.2, you get back:<\/p>\n\n\n\n<p><strong><em>HTTP\/1.1 412 Precondition Failed<\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What does that mean in practice?<\/h2>\n\n\n\n<p>The server is actually saying: you are working with outdated information. The resource you're trying to change is no longer what you think it is. So we stop the process.<\/p>\n\n\n\n<p>And that is exactly what you want in this kind of system. You don't want race conditions. You don't want users overwriting each other's changes. You want control.<\/p>\n\n\n\n<p>Sometimes you see 412s in logs from frameworks that enforce version control via ETags. Integrations between different systems can also return them in case of invalid edit conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you solve it?<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"502\" src=\"https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-1024x502.jpeg\" alt=\"HTTP 412\" class=\"wp-image-16128\" srcset=\"https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-1024x502.jpeg 1024w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-300x147.jpeg 300w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-768x376.jpeg 768w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-1536x752.jpeg 1536w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412-18x9.jpeg 18w, https:\/\/surver.nl\/wp-content\/uploads\/2025\/07\/http-412.jpeg 1678w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Are you getting a 412? Then it's smart to first retrieve the current version of the resource again. See what has changed and decide if you still want to make the change, but based on the latest state.<\/p>\n\n\n\n<p>In REST APIs, you often do that by first doing a GET, fetching the new ETag, and then a new PUT or PATCH with a correct If-Match.<\/p>\n\n\n\n<p>Sometimes it is smarter to update without a condition, but that depends on the context. Competing on one resource can lead to data loss, which is exactly what the 412 is for.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">In conclusion<\/h2>\n\n\n\n<p>The <strong>412 status code<\/strong> is technical, but not illogical. He is there to protect you from erroneous updates, not to thwart you.<\/p>\n\n\n\n<p>You only get it if you've set a condition yourself, and it's no longer true. And that's a good thing. Because you don't want to blindly overwrite something you thought was still the same.<\/p>\n\n\n\n<p>Do you work with many integrations, web shops or content APIs? Then it's smart to invest in reliable <a href=\"https:\/\/surver.nl\/en\/managed-hosting\/wordpress\/\">WordPress Hosting<\/a>, scalable <a href=\"https:\/\/surver.nl\/en\/managed-hosting\/cloud\/\">Cloud Hosting<\/a> or specialized <a href=\"https:\/\/surver.nl\/en\/managed-hosting\/woocommerce\/\">WooCommerce Hosting<\/a> to avoid this type of dependency error.<\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Sommige HTTP-fouten zijn helder. Een 404 betekent dat iets niet bestaat. Een 403 zegt dat je ergens niet bij mag. Maar een 412 status code? Die komt minder vaak voor, en roept daardoor des te meer vragen op. Toch is het technisch gezien een logische foutmelding. Geen kapotte URL, geen syntaxfout. Gewoon: een voorwaarde die [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":16372,"template":"","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"kennisbank_categorieen":[64],"class_list":["post-16127","kennisbank","type-kennisbank","status-publish","has-post-thumbnail","hentry","kennisbank_categorieen-statuscodes"],"acf":[],"_links":{"self":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank\/16127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank"}],"about":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/types\/kennisbank"}],"author":[{"embeddable":true,"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/media\/16372"}],"wp:attachment":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/media?parent=16127"}],"wp:term":[{"taxonomy":"kennisbank_categorieen","embeddable":true,"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank_categorieen?post=16127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}