MSGraph set query page size (instead of using skip

2019-09-19 01:44发布

问题:

How would I go about fetching all users from a company, the following query still only returns 100 items:

https://graph.microsoft.com/v1.0/users?$pageSize=200

Though this might be because the documentation says:

Paging is not supported for link searches, such as for querying group members.

I assume this applies to the users query. Though I don't fully understand why, nor do I understand how else I would fetch the rest of the users.

Any help would be appreciated.

edit: Okay so I found out every page gives you a skiptoken, which is an url to the next page of users. This makes things a lot more complicated than they need to be. I'll rephrase this question to; is there an easier way to fetch all users?

回答1:

Haven't used pageSize param myself but I've used $top which should behave similarly. Using top you can tell graph to return up to 999 results, which is enough hopefully.

Skip tokens make stuff more complicated, however they do provide you with access to paging/infinite scroll (however you wish to implement your logic). And if you do not need that, you can just do $top=999 for how many times do you need and return the aggregated results.