Directory_ExpiredPageToken error when paginating users

semptrastr 10 Reputation points
2023-12-14T11:53:13.09+00:00

We are using the following request to list all users with specified filter:

var usersResponse = await graphServiceClient.Users.GetAsync(requestConfiguration =>
{
    requestConfiguration.QueryParameters.Select = new string[] { "id", "displayName", "userPrincipalName" };
    requestConfiguration.QueryParameters.Filter = "accountEnabled eq true";
    requestConfiguration.QueryParameters.Top = 50;
});

var users = new List
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,193 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 45,186 Reputation points
    2023-12-15T07:02:14.6466667+00:00

    Hi @semptrastr

    This looks like an issue due to an expired pagination token. The paging token has a short expiration time and will expire if you don't request the next page in time. You can use advanced query capabilities in your requests, so that you will get more robust and less prone to expire pagination tokens.

    Or you can also use the $skip query parameter to skip the data that has been obtained, instead of relying on the pagination token.

    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.