Problem retriving data from SharePoint list using C# Graph SDK

Copper Contributor

We recently experienced a problem retrieving data from a SharePoint list using the following code:

IListItemsCollectionPage spList = Task.Run(() => { return graphClient?.Sites[siteId]?.Lists[listName]?.Items?.Request()?.Expand("Fields")?.Top(100).GetAsync(); })?.Result;

while (spList.Count > 0)
{
  if (spList.NextPageRequest != null)
    spList = Task.Run(() => { return spList.NextPageRequest.GetAsync(); })?.Result;
  else
    break;
}

Data is retrieved every 10 minutes and every so often (sometimes every 10 minutes, sometimes everything works fine all day) we get an exception when requesting the next page:

Code: invalidRequest
Message: One of the provided arguments is not acceptable.

The problems started recently, previously everything was working fine. Do you have any ideas what might be causing this problem?

0 Replies