Forum Discussion
Threshold issue when Performing operation on 5000+ Items in a library
Hi,
We are performing operation on list having 5000+ items. i
I find that any CSOM operation on the List having 5000+ throws the threshold error .
I have this code mentioned below
Whenever I try to load below statements for a list having 5001 docs it is throwing threshold error.
Is this a limitation using CSOM ?
How to over come this issue ?
Error: "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator"
cContext.Load(list2.RootFolder.Folders);
Sample code:
string fileUrl = "https://***.sharepoint.com/sites/***";
Uri fileUri = new Uri(fileUrl);
var x = fileUri.Scheme + Uri.SchemeDelimiter + fileUri.Host;
ClientContext rootContext = new ClientContext(fileUri.Scheme + Uri.SchemeDelimiter + fileUri.Host);
rootContext.Credentials = BuildCreds();
Uri webUrl = Web.WebUrlFromPageUrlDirect(rootContext, fileUri);
ClientContext cContext = new ClientContext(webUrl.ToString());
cContext.Credentials = BuildCreds();
cContext.Load(cContext.Web);
cContext.ExecuteQuery();
ListCollection siteLists = cContext.Web.Lists;
cContext.Load(siteLists);
cContext.ExecuteQuery();
foreach (List list2 in siteLists)
{
try
{
cContext.Load(list2);
cContext.Load(list2.RootFolder);
cContext.Load(list2.RootFolder.Folders);
cContext.ExecuteQuery();
}
catch
{
}
}
Thanks
Mahadev
1 Reply
- Micca0815Iron Contributor
mkarekar
You might want to peek a little within https://github.com/PowershellScripts/SPOMod GitHub repository of https://social.technet.microsoft.com/wiki/contents/articles/51763.user-page-arleta-wanat.aspx#SharePoint_Online.
As an alternative you could use this https://github.com/pnp/PnP-PowerShell/blob/master/Commands/Lists/GetListItem.cs of the https://github.com/pnp/PnP-PowerShell as reference instead.
For pagination the https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee537050(v=office.15) can be utilized.