Share via

UserCollectionPage has an API "getCurrentPage()" type List<User> returns 100 users, what API to get list of all users?

Sharad Dutta 26 Reputation points
2021-10-18T08:05:27.48+00:00

0

I am trying to access a b2c directory using Graph API to get all the users inside it...So far I have 800+ users however using below snippet I could only get 100 users.

UserCollectionPage users = graphClient.users()
.buildRequest()
.get();
List<User> userList = users.getCurrentPage();

So I have created a graph client and ideally I should get back all the users in object "users" however I was only able to get 100 users, I tried to debug and found so...

One more bug that I noticed in the API was that the userType in debugger expression window for all user was NULL which is wrong because all the users are of userType - member...

Is anybody aware of what the correct API is to list all the users at once? I do not mind if the listing is based on JSON, but the more important thing would be to list all 800+ users.

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,456 Reputation points
    2021-10-19T02:52:07.323+00:00

    Hi, dear @Sharad Dutta

    It paginates with 100 pieces of data by default. If you want to get all users on one page, you can modify your code:

    UserCollectionPage users = graphClient.users()  
     .buildRequest()  
     .top(900)  
     .get();  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

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