-
Notifications
You must be signed in to change notification settings - Fork 260
Description
Describe the bug
Hi, I am trying to get all sites for our tenant and loop through them to find certain ones. We have more than 200 sites, a lot of them personal. I learned that using the PageIterator is the best way to go about this. However, I cannot for the life of me get it to work with the last stable version of the SDK with either .NET 8 or .NET 9.
The following is my code:
private async Task<List> GetAllSitesGetResponse()
{
var allSites = new List<Site>();
var firstPage = await _graphClient.Sites.GetAllSites.GetAsGetAllSitesGetResponseAsync();
var pageIterator = PageIterator<Site, SiteCollectionResponse>
.CreatePageIterator(
_graphClient,
firstPage,
(site) =>
{
allSites.Add(site);
return true;
},
// This is optional func
(req) =>
{
return req;
}
);
await pageIterator.IterateAsync();
return allSites;
}
And this error I get in Visual Studio:

I've also tried returning Task.FromResult(true); but this also does not work:

Would appreciate any help. We are desperate to get this project wrapped up. Much appreciated!
Expected behavior
The CreatePageIterator's callback parameter should accept my return boolean type of 'true'.
How to reproduce
Just try the code I provided above with the following SDK version and .NET 8 or .NET 9.
SDK Version
5.93.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
Windows 11 24H2
### Other information
_No response_