Aug 11 2020 12:44 PM
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
Aug 11 2020 10:30 PM
@mkarekar
You might want to peek a little within this GitHub repository of Arelat Wanat.
As an alternative you could use this cmdlet of the PNP module as reference instead.
For pagination the ListItemPosition can be utilized.