docs:
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/make-batch-requests-with-the-rest-apis
sample project using odata
https://github.com/pnp/PnP/tree/master/Samples/Core.ODataBatch/Core.ODataBatchWeb/Pages
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Have examples of this in c# please?
Hi @nellie ,
According to my research and testing, you can use the following code to create/update/delete list items in batch using CSOM :
var ctx = GetonlineContext();
Web spWeb = ctx.Web;
spWeb = ctx.Web;
ctx.Load(spWeb);
List spList = spWeb.Lists.GetByTitle("<ListName>");
//Create SharePoint List Items In Batch
for (var i = 1; i < 20; i++)
{
try
{
ListItemCreationInformation spItemInfo = new ListItemCreationInformation();
ListItem spItem = spList.AddItem(spItemInfo);
spItem["Title"] = "MyNewItem-" + i.ToString();
spItem.Update();
}
catch (Exception ex) {
Console.WriteLine("Error:- " + ex.ToString());
}
}
ctx.ExecuteQuery();
//update SharePoint List Items In Batch
/*
for (var i = 1; i < 20; i++)
{
try
{
ListItem spItem = spList.GetItemById(i);
spItem["Title"] = "UpdatedItem-"+i.ToString();
spItem.Update();
}
catch (Exception ex)
{
Console.WriteLine("Error:- " + ex.ToString());
}
}
ctx.ExecuteQuery();
*/
//delete SharePoint List Items In Batch
/*
for (var i = 1; i < 10; i++)
{
try
{
ListItem spItem = spList.GetItemById(i);
spItem.DeleteObject();
}
catch (Exception ex)
{
Console.WriteLine("Error:- " + ex.ToString());
}
}
ctx.ExecuteQuery();
*/
More information for reference:
https://www.c-sharpcorner.com/blogs/create-sharepoint-list-items-in-batch-using-csom2
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.