I am using Graph Client 2.0.8 and fetching users. My tenant has more that 10K Users.
Problem : I am using Graph Client 2.0.8 and want to bring 5000 users. In Graph client I have specified each time bring 999, but Api only bring 999 records first time and then it bring only 100 records. However, I have specified 999 records in next page request as well. Here is code snippet
ActiveDirectoryClient graphConn = GraphServiceHelper.GetGraphConnection(TenantDomain, UserAccessToken, TraceId);
userCollection = graphConn.Users;
users = await userCollection.Take(ResultBatchSize).ExecuteAsync();
if (users != null)
{
do
{
// Convert User to UserModel DTO
var usersListModel = users.CurrentPage.Take(999).ToList();
isMoreRecordsAvailable = users.MorePagesAvailable;
if (usersListModel.Count() >= 5000 || !users.MorePagesAvailable) // exit if batch sized reach.
break;
else
users = await users.GetNextPageAsync();
} while (true);
}
How to bring 999 records in each subsequent call? Appreciate your help.