Is there any way to update bulk list items using REST API in sharepoint online site. Thanks in advance
2 Answers
In SharePoint Online, the Rest API does support batch operations. If you are using PnP then things will become easier for you in this regard:
Sample from PnP Documentation: Source
import { sp } from "@pnp/sp";
let list = sp.web.lists.getByTitle("rapidupdate");
list.getListItemEntityTypeFullName().then(entityTypeFullName => {
let batch = sp.web.createBatch();
// note requirement of "*" eTag param - or use a specific eTag value as needed
list.items.getById(1).inBatch(batch).update({ Title: "Batch 6" }, "*", entityTypeFullName).then(b => {
console.log(b);
});
list.items.getById(2).inBatch(batch).update({ Title: "Batch 7" }, "*", entityTypeFullName).then(b => {
console.log(b);
});
batch.execute().then(d => console.log("Done"));
});
-
Oh, wow, I had no idea PnP Js had batch operation. Thank you for posting it! Dec 1, 2018 at 0:59
-
Stand alone batchutility is also there take a look github.com/anomepani/sp-rest-util/blob/master/BatchUtils.ts Jul 25, 2019 at 3:51
You can batch queries and operations against the REST/OData API of Microsoft SharePoint Online (and on-premises SharePoint 2016 and later) and the Files and folders subset of the Office 365 REST APIs.
The request URL consists of the root service URL and the $batch
option.
For example:
https://fabrikam.sharepoint.com/_api/$batch
Or
https://fabrikam.office365.com/api/v1.0/me/$batch
Reference: