Graph SDK | .orderBy not working in B2C tenants

Diego 0 Reputation points
2024-06-04T13:08:42.0433333+00:00

Hi,

I would like to read out all users with the Microsoft Graph SDK (Typescript) and get them sorted by the "createdDateTime".

In normal Azure tenants this works without any problems, but in a B2C tenant it does not work so far.

This is how my query looks:

let response = await client.api('/users')

                .count(true)

                .header('ConsistencyLevel','eventual')

                .filter(`createdDateTime ge 2023-01-01T00:00:00Z and createdDateTime le 2023-12-31T23:59:59Z`)

                .select('userPrincipalName, createdDateTime, mail, id, displayName')

                .orderby('createdDateTime')

                .top(100)

                .get();

  • Am I doing something wrong?
  • Or does this really not work for B2C clients?

If I remove the .orderby its working - but I really need this.

Best regards

Diego

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,334 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 45,841 Reputation points
    2024-06-05T03:02:07.6733333+00:00

    Hi @Diego

    Sorting the set of users using the createdDateTime property is an advanced query, but advanced queries do not support Azure AD B2C tenants, so you cannot currently sort using the createdDateTime property for Azure AD B2C tenant users.

    User's image

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.