I'm trying to iterate recursively over all documents in a given site. This is what I'm using:
using (System.IO.StreamWriter file = new System.IO.StreamWriter("docs.txt"))
{
foreach (var lib in docLibs)
{
CamlQuery query = new CamlQuery();
query.ViewXml = "<View Scope = 'RecursiveAll'></View>";
ListItemCollection items = lib.GetItems(query);
clientContext.Load(items);
clientContext.ExecuteQuery(); // Exception thrown here
foreach (var item in items)
{
Microsoft.SharePoint.Client.File f = item.File;
if (f.ServerObjectIsNull.HasValue && !(bool)f.ServerObjectIsNull)
file.WriteLine(f.Name);
}
}
}
The error I'm getting is "The request uses too many resources" I'm guessing some List in my site has too many documents and therefore one of the requests is failing. Is there anyway to retrieve the documents chunk by chunk or some other approach to retrieve all documents?