Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to avoid concurrency using etag in sharepoint?


Asked by Edgar McPherson on Dec 01, 2021 FAQ



If you are getting only one element using a GET request, you will be able to get Etag using the code mentioned below. If you are getting multiple elements using a GET request, you will be able to get Etag using the code mentioned below. Here, i is the index of the row item in the result set. How Etag is connected to concurrency?
One may also ask,
ETag value is a part of the HTTP protocol that allows concurrency control and web cache validation. ETag is a broader topic when considered in general, but the main focus on this article is to discuss about REST API usage within SharePoint.
In fact, With the adherence to the OData standards, we can do this and more using eTags to manage concurrency. Concurrency control is a thorny problem in computer science. It refers to the situation where more than one person requests to change (either via update or delete) a piece of data stored somewhere.
Keeping this in consideration,
The ETag is a part of HTTP, it could be used for optimistic concurrency control as a way to help prevent ghost writes. Please check the following article for more details:
And,
- You can pass a header "IF-MATCH" in your REST API call. If the Etag values don’t match it will throw an error like below. Here we are going to update a list item. HTML and REST API code is given below. Comments are given to easily understand the code.