Forum Discussion

mszorc's avatar
mszorc
Copper Contributor
Jul 16, 2021

Problem retriving data from SharePoint list using C# Graph SDK

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?

No RepliesBe the first to reply

Resources