question

SharadDutta-5319 avatar image
0 Votes"
SharadDutta-5319 asked CarlZhao-MSFT commented

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

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-graph-users
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT commented

Hi, dear @SharadDutta-5319

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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, dear @SharadDutta-5319 Would you please provide us with an update on the status of your issue?

0 Votes 0 ·