【问题标题】:Microsoft Graph API Pagination Users.NextPageRequest.GetAsync() return error with message Invalid next page search requestMicrosoft Graph API 分页 Users.NextPageRequest.GetAsync() 返回错误并显示无效的下一页搜索请求
【发布时间】:2021-07-09 17:56:09
【问题描述】:

我试图从下一页拉 B2C 用户,但收到以下错误: 代码:Request_UnsupportedQuery 消息:无效的下一页搜索请求。 内部错误: 附加数据: 日期:2021-07-08T20:25:20 请求 ID:7fd74717-0f7b-467f-9753-64c416fe5902 客户端请求 ID:7fd74717-0f7b-467f-9753-64c416fe5902 ClientRequestId: 7fd74717-0f7b-467f-9753-64c416fe5902

问题是我使用相同的代码来获取 AAD 用户,它可以工作,但不知何故不适用于 B2C 用户! 这是我正在使用的代码:

    //read B2C
ClientCredentialProvider authProviderB2C = new(this.B2CClientApp);

// Create a new instance of GraphServiceClient in B2C with the authentication provider.
GraphServiceClient graphClientB2C = new(authProviderB2C);

var b2cUsers = await graphClientB2C.Users
                    .Request()
                    .Filter($"identities/any(c:c/issuer eq '{AppSettingsProvider.AADIssuer}')")
                    .Top(999)
                    .Select(u => new {
                        u.DisplayName,
                        u.Id,
                        u.Mail,
                        u.UserPrincipalName,
                        u.Identities
                    })
                    .GetAsync();

// Create a bucket to hold the final B2C users result
var b2cUserList = new List<User>();

// Add the first page of data to the final B2C user list
b2cUserList.AddRange(b2cUsers.CurrentPage);

// Repeate until all pages have been returned
while (b2cUsers.NextPageRequest != null)
{
    b2cUsers = await b2cUsers.NextPageRequest.GetAsync();
    b2cUserList.AddRange(b2cUsers.CurrentPage);
}

调用 b2cUsers = await b2cUsers.NextPageRequest.GetAsync(); 时出现上述错误;

非常感谢任何帮助。谢谢。

【问题讨论】:

  • 在构建代码之前,我总是使用 Microsoft Graph Explorer 或 POSTMAN 测试 API 调用,看看它是否适合我。我也建议你这样做。
  • @Dev 谢谢。我确实使用两者来测试,但不知道如何在 POSTAM 中发送对第二页的请求。无论如何,问题是具有身份的过滤器不支持分页,即使 NextPageRequest 存在并且!= null。因此,作为一种解决方法,我将过滤器更改为支持分页的过滤器。
  • 很高兴它帮助了@Adam。

标签: microsoft-graph-api


【解决方案1】:

问题是带有身份的过滤器不支持分页,即使 NextPageRequest 存在并且 != null。

【讨论】:

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