Reputation: 51
I am trying to pull B2C users from the next page but gets the following error: Code: Request_UnsupportedQuery Message: Invalid next page search request. Inner error: AdditionalData: date: 2021-07-08T20:25:20 request-id: 7fd74717-0f7b-467f-9753-64c416fe5902 client-request-id: 7fd74717-0f7b-467f-9753-64c416fe5902 ClientRequestId: 7fd74717-0f7b-467f-9753-64c416fe5902
The problem is I'm using the same code to get AAD users and it works but somehow doesn't for B2C users!! here is the code I'm using:
//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);
}
It gives me the above error when calling b2cUsers = await b2cUsers.NextPageRequest.GetAsync();
Any help is much appreciated. Thank you.
Upvotes: 3
Views: 1840
Reputation: 51
The issue is that the filter with identities somehow doesn't support paging even though NextPageRequest is there and != null.
Upvotes: 2