to get a personalized navigation.
to get a personalized navigation.
In modern web applications, ensuring data consistency and preventing conflicts is essential, especially when multiple clients attempt to update the same resource concurrently. The ETag and If-Match HTTP headers offer a solution for these challenges. Here's how they work together to maintain data integrity.
An ETag (Entity Tag) is a unique identifier that the server assigns to a specific version of a resource. It is included in the response header when a client requests the resource. This identifier helps clients in managing cache and detecting resource changes.
The If-Match HTTP header is used by clients to signal that they wish to update a resource only if its current version matches a specific ETag. This mechanism prevents resource conflicts when multiple clients try to update the same resource simultaneously.
See also, lost update problem, If-Match, HTTP conditional requests
1) GET : .../api/v1/supplier/xxxxx
Response headers : ETag
Response body : timeStamp
2) PUT: .../api/v1/supplier/xxxxx
Request headers : If-Match
This request will succeed in updating the resource only if the resource's current "ETag" is "AAAAAE0YIiI=".
A) In case of success, the server returns "204 - No content" together with the new ETag value in the response headers.
B) In case of failure, the server returns "412 - Precondition Failed".
ℹ️ PUT: The ETag of the recently updated entity is included in the response header.
ℹ️ POST: The ETag of the recently created entity is included in the response header.
Note: : "TimeStamp" field can also be checked via the DTOs where it's exposed.
If the endpoint is asynchronous,
meaning that if it is immediately returning a “202-Accepted” HTTP response and starts the actual job in the background, such as “Action” based operations. (Endpoint URL: …/action/…)
If-Match is supported in the following actions only with “erp-api-background usage,
----------------------------------------------------------------------------------------------------------------------------------------
We're currently working on updating the swagger documentation, once the work is done, function will be listed on all the related operations / actions accordingly.
This knowledge article serves as a guide for developers to incorporate ETag and If-Match functionality into their applications, ensuring smooth updates and mitigating conflicts in a multi-client environment.
Copyright © 2022 Visma.com. All rights reserved.