Reputation: 307
While fetching Microsoft 365 Groups using Graph Api (Permission type: Delegated) - I got only 100 Group Count (see below screenshot) - I believe this has to be with pagination however the how to get the next bunch of group ? (like nextlink)
IGraphServiceGroupsCollectionPage groupCollection = await graphClient.Groups.Request().GetAsync();
if (groupCollection?.Count > 0)
{}
Upvotes: 0
Views: 780
Reputation: 1771
When using the SDK, here is how you can paginate the groups. Note I have added .Top(2) to get pagination on a few groups.
var groups = new List<Group>();
var groupsPage = await graphServiceClient.Groups.Request().Top(2).GetAsync();
groups.AddRange(groupsPage.CurrentPage);
while (groupsPage.NextPageRequest != null)
{
groupsPage = await groupsPage.NextPageRequest.GetAsync();
groups.AddRange(groupsPage.CurrentPage);
}
Upvotes: 1