Update A SharePoint List Item Without Increasing Its Item File Version Using Rest API

Introduction

 
In this article, we learn how to update a SharePoint List Item without increasing its item file version. We will be using the SharePoint REST API for this purpose.
 

Description

 
I came across one specific requirement that while updating document metadata fields like Title or Other fields, the version field should not be incremented.
 
If you know how SharePoint handles versioning for all document libraries, you are aware that even if you make smaller changes in updating Fields or content of the document, it increments the version of the document.
 
I have found a similar solution using CSOM over here Posted by Srikant Barik.
 
But we want a solution using the REST API. After some research, I have found the solution.
 
In Sharepoint Online, I have found "ValidateUpdateListItem" POST Endpoint at ListItem level.
  1. // Sample Request Url  
  2. reqUrl= "https://brgrp.sharepoint.com/_api/web/Lists/GetbyTitle('Documents')/items(1)/ValidateUpdateListItem";   
  3.   
  4. //payload for request   
  5.  body=  {"formValues":[{"FieldName":"Title","FieldValue":"Single Update Title with versioning"}],bNewDocumentUpdate:true}  
 From the above URL, a sample request is provided and also, the payload for request is already there.
 
In "formValues", you can add multiple columns as well to update items.
 
If you do not provide bNewDocumentUpdate value it will take default value false. This field is responsible for incrementing version or not for specific list item.
 
A false value indicates that it will increment the version of the file and True value indicates that it will not increment the version of the file or list item.
 

See Full Source Code

  1. //payload for request   
  2.  body=  {"formValues":[{"FieldName":"Title","FieldValue":"Single Update Title with versioning__"}],bNewDocumentUpdate:true}  
  3.   
  4.  //Header data for sharepoint POST Request  
  5.  var _payloadOptions = {  
  6.                 method: "POST",  
  7.                 body: undefined,  
  8.                 headers: {  
  9.                     credentials: "include",  
  10.                     Accept: "application/json; odata=verbose",  
  11.                     "Content-Type""application/json; odata=verbose"  
  12.                 }  
  13.             };  
  14.   
  15. //Get RequestDigest First  
  16. fetch("https://brgrp.sharepoint.com/_api/contextinfo",_payloadOptions).then(r=>r.json())  
  17. .then(r=>  
  18.                                    {  
  19. _payloadOptions.headers["X-RequestDigest"]=r.d.GetContextWebInformation.FormDigestValue  
  20.       
  21. _payloadOptions.body=JSON.stringify(body);  
  22.   
  23. // Make REST API Call to update list item without increamenting version.  
  24. fetch("https://brgrp.sharepoint.com/_api/web/Lists/GetbyTitle('Documents')/items(1)/ValidateUpdateListItem()"
  25. ,_payloadOptions).then(r=>r.json()).then(r=>console.log(r))  
  26. })