We have an Azure Web App, written in C#, that saves PDFs to our SharePoint Documents site. I have put an index on a few columns as suggested by Microsoft. I made sure there were no sorting, grouping, or totals on the library settings. I have added a caml query to limit rows and to order by the indexed column. I have also tried to use a where clause in the loadquery() call and an include statement I load() call to include the indexed column. I have copied and pasted code off the web and cannot get it to not give me the above error. I did find a PowerShell script that did much of what I did in the C# program and it worked. Sadly there are no C# programmers here any longer and I am stuck with trying to blunder my way through. See below the code I am trying to use:
Web rootWeb = context.Web;
var query = context.LoadQuery(rootWeb.Lists.Where(p => p.Title == "Documents"));
context.ExecuteQuery();
List list = query.FirstOrDefault();
CamlQuery cquery = new CamlQuery();
cquery.ViewXml = @"
<View Scope='RecursiveAll'>
<Query>
<OrderBy Override='TRUE'>
<FieldRef Name='Title' Ascending='TRUE' />
</OrderBy>
</Query>
<RowLimit Paged='TRUE'>4</RowLimit>
</View>";
ListItemCollection collListItem = list.GetItems(cquery);
context.Load(collListItem, items => items.Include(item => item.Title));
context.ExecuteQuery(); # <--- Of course this is where the error occurs.
I have been working on this for days and cannot figure out what I am NOT doing. Any help would be greatly appreciated. Also what I believe it is trying to get is a list of our folders and not items, not sure if that matters.