Problem retriving data from SharePoint list using C# Graph SDK

%3CLINGO-SUB%20id%3D%22lingo-sub-2555157%22%20slang%3D%22en-US%22%3EProblem%20retriving%20data%20from%20SharePoint%20list%20using%20C%23%20Graph%20SDK%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2555157%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20recently%20experienced%20a%20problem%20retrieving%20data%20from%20a%20SharePoint%20list%20using%20the%20following%20code%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EIListItemsCollectionPage%20spList%20%3D%20Task.Run(()%20%3D%26gt%3B%20%7B%20return%20graphClient%3F.Sites%5BsiteId%5D%3F.Lists%5BlistName%5D%3F.Items%3F.Request()%3F.Expand(%22Fields%22)%3F.Top(100).GetAsync()%3B%20%7D)%3F.Result%3B%0A%0Awhile%20(spList.Count%20%26gt%3B%200)%0A%7B%0A%20%20if%20(spList.NextPageRequest%20!%3D%20null)%0A%20%20%20%20spList%20%3D%20Task.Run(()%20%3D%26gt%3B%20%7B%20return%20spList.NextPageRequest.GetAsync()%3B%20%7D)%3F.Result%3B%0A%20%20else%0A%20%20%20%20break%3B%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EData%20is%20retrieved%20every%2010%20minutes%20and%20every%20so%20often%20(sometimes%20every%2010%20minutes%2C%20sometimes%20everything%20works%20fine%20all%20day)%20we%20get%20an%20exception%20when%20requesting%20the%20next%20page%3A%3C%2FP%3E%3CP%3ECode%3A%20invalidRequest%3CBR%20%2F%3EMessage%3A%20One%20of%20the%20provided%20arguments%20is%20not%20acceptable.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20problems%20started%20recently%2C%20previously%20everything%20was%20working%20fine.%20Do%20you%20have%20any%20ideas%20what%20might%20be%20causing%20this%20problem%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2555157%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New 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