【发布时间】:2021-07-11 07:33:31
【问题描述】:
我们正在使用 Microsoft Graph API Beta 版使用以下代码从 Azure AD 检索所有用户。 API 在响应中仅返回 100 个用户,为了使用分页响应,我们尝试了 NextPageRequest 属性。但它总是为NextPageRequest 属性返回null。因此,它永远不会进入 while 循环来检索其余用户。
Beta SDK 版本:4.0.1.0
代码:
List<User> usersList = new List<User>();
IGraphServiceUsersCollectionPage users = await graphClient.Users.Request().GetAsync();
// Add the first page of results to the user list
usersList.AddRange(users.CurrentPage);
// Fetch each page and add those results to the list
while (users.NextPageRequest != null)
{
users = await users.NextPageRequest.GetAsync();
usersList.AddRange(users.CurrentPage);
}
log.Info("Users count: " + usersList.Count.ToString());
return usersList;
我关注的参考链接:
- Microsoft Graph only returning the first 100 Users
- https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=csharp
对此的任何帮助将不胜感激!
【问题讨论】:
标签: c# microsoft-graph-api microsoft-graph-sdks beta