【问题标题】:Get Users using Delta query does not return the nextLink or deltaLink with C# code使用 Delta 查询获取用户不会返回带有 C# 代码的 nextLink 或 deltaLink
【发布时间】:2021-08-06 15:21:13
【问题描述】:

我在 Azure 中注册了一个应用程序并提供了所需的权限,并使用该应用程序通过 delta Query 检索修改后的用户。

下面是代码。

var pagedCollection = await graphClient.Users
                      .Request()
                      .Delta()
                      .Select("userPrincipalName,mobilePhone")
                      .GetAsync();

但响应不包含文档中提到的 nextLinkdeltaLink

如果我在图形资源管理器中测试 API,我可以获得上述链接。

https://graph.microsoft.com/v1.0/users/delta

来自 Graph Explorer 的响应。

我在使用 C# 调用相同的 API 时是否遗漏了什么?

对此的任何帮助将不胜感激!

【问题讨论】:

    标签: c# azure-active-directory microsoft-graph-api


    【解决方案1】:

    你可以试试下面的代码:

                    List<Microsoft.Graph.User> usersList = new List<Microsoft.Graph.User>();
                    var users = await graphClient.Users.Delta().Request().Top(10).GetAsync();
    
                    // Add the first page of results to the user list
                    usersList.AddRange(users.CurrentPage);
    
                    try
                    {
                        while (users.AdditionalData.ContainsKey("@odata.nextLink") && users.AdditionalData["@odata.nextLink"].ToString() != null)
                        {
                            users.InitializeNextPageRequest(graphClient, users.AdditionalData["@odata.nextLink"].ToString());
                            users = await users.NextPageRequest.GetAsync();
                            usersList.AddRange(users.CurrentPage);
                        }
                    }
                    catch (Exception e)
                    {
    
                    }
    

    参考链接:Microsoft Graph API Pagination is not working for getting all users from Azure AD

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 1970-01-01
      相关资源
      最近更新 更多