The attempted operation is prohibited because it exceeds the list view threshold

Copper Contributor

Hi,

 

We are fetching documents from a specific folder using the below code. 

 

 

 

 

Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Testable");
    clientContext.Load(spList);
    clientContext.ExecuteQuery();

    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
                                                  <Query>
                                                      <Where>
                                                          <IsNotNull>
                                                              <FieldRef Name='Title'></FieldRef>
                                                          </IsNotNull>
                                                      </Where>
                                                      <OrderBy>
                                                       <FieldRef Name='Created' Ascending='true' />
                                                     </OrderBy>
                                                  </Query>
                                                </View>";

    Folder folder = clientContext.Web.GetFolderByServerRelativeUrl(relativeURL);
    clientContext.Load(folder);
    clientContext.ExecuteQuery();

    camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
    ListItemCollection listItems = spList.GetItems(camlQuery);

    clientContext.Load(listItems, items => items.Include(
    item => item, item => item["Title"]));
    clientContext.ExecuteQuery();

 

 

 

The folder has 10-12 documents only but still, it is throwing the error  "The attempted operation is prohibited because it exceeds the list view threshold" when executing the last line.

0 Replies