I have to create more than 20000 data in a SharePoint list using CSOM.

I have written program and it is working fine adding items to list but as the number of items is huge, it takes time to create that many items.

So I needed few suggestion to do it in a better way, like if I can do something like creating 100 items at a time in list and then the next 100 items so that the code runs efficiently and no such issues occur like connection lost or connection timed out.

Please suggest if directly creating more than 20000 items is correct way or if I can do something so that the code does not break.

  • Could you please add your code?
    – Gintas K
    Mar 3, 2017 at 11:01
  • Did you get any solution for this? I am also facing this same issue link Jan 27, 2020 at 17:17

1 Answer 1


Using CSOM 2 ways you can the item adding to lists in sharepoint

  1. Using any dot net Console/Windows application/web application and referencing the client dlls you can add list items to SharePoint list. Microsoft.SharePoint.Client.dll Microsoft.SharePoint.Client.Runtime.dll

  2. You can do through CSOM Powershell to add the list items to SharePoint list by refenrencing the same dlls Microsoft.SharePoint.Client.dll Microsoft.SharePoint.Client.Runtime.dll.

I suggest for bulk uploads or bulk data add to SharePoint list you use 2nd approach(Powershell CSOM)

Here is the code sample to add the list items to sharePoint list

Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"   #path of the client dll
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   #path of the client dll

$siteURL = "https://Siteurl"  #You provide Site URL 
$userId = "UserID"  # Give user id eg: domain\user  
$pwd = Read-Host -Prompt "Enter password" -AsSecureString  
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)  
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)  
$ctx.credentials = $creds  
    $lists = $ctx.web.Lists  
    $list = $lists.GetByTitle("TestList")  
    $listItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation  
    $listItem = $list.AddItem($listItemInfo)  
    $listItem["Title"] = "c"  
    Write-Host "Item Added with ID - " $listItem.Id      
catch [System.Exception] 
  Write-Host -ForegroundColor Red $_.Exception.ToString()    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.