Hi @nicholas dipiazza ,
I tested the same CAML in a custom list which have 5300 items and it's working:
using (var context = new ClientContext("https://zheguo.sharepoint.com/sites/dev/"))
{
context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(userName, securePassword);
Web web = context.Web;
context.Load(web);
context.ExecuteQuery();
var list = context.Web.Lists.GetByTitle("CamlList");
Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml =
@"<View><Query><OrderBy><FieldRef Name = 'ID' Ascending = 'FALSE'/></OrderBy></Query><ViewFields><FieldRef Name = 'ID'/></ViewFields><RowLimit>1</RowLimit></View>";
ListItemCollectionPosition itemPosition = null;
do
{
ListItemCollection itemCollection = null;
itemCollection = list.GetItems(camlQuery);
context.Load(itemCollection);
try
{
context.ExecuteQuery();
Console.WriteLine(itemCollection[0].FieldValues["ID"]);
}
catch (Exception exec)
{
Console.WriteLine(exec.ToString());
}
}
while (itemPosition != null);
}
Console.ReadLine();
The ID column is indexed column by default, so the caml to order by ID column should be working.
I suggest you can try again to see if it works and as the error only happen for a specific list, I suggest you can check if there is some special for the list.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.