0
votes

Microsoft Graph API is not returning more than 100 object

I tried below query to get "memberof" details of a particular user. However it return only first 100 objects. However User is member of 210 groups. Could you please help me with correct query

https://graph.microsoft.com/v1.0/users/[email protected]/memberOf

GET https://graph.microsoft.com/v1.0/users/[email protected]/memberOf

3
This is the correct API but its tough to test without having more then 100 usersMd Farid Uddin Kiron

3 Answers

3
votes

The response should contain a "@odata.nextLink" field which can be used to retrieve the next page of the result. An example response could be:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/users/[email protected]/memberOf?$top=5&$skiptoken=X%2744537074090001000000000000000014000000B2B64E48AF94EB439F56F5A33CB75C9301000000000000000000000000000017312E322E3834302E3131333535362E312E342E32333331020000000000011C7FEE5EFEFA46459248691C529273D3%27",
    "value": [
    { ... }
    ...
    ]
}

To retrieve all results we should keep following "@odata.nextLink" of each responses until the response does not contain a "@odata.nextLink" field.

1
votes

Please have a look at this doc explaining how paging works in Microsoft Graph: https://docs.microsoft.com/graph/paging

It works the same with the /memberOf API

0
votes

You can use query parameters to customize responses - like so for example get the top 300 - this will return til 300 groups etc

https://graph.microsoft.com/v1.0/users/[email protected]/memberOf?$top=300

This is a quick and dirty way, since the memberOf method does not support all OData Query Parameters

https://docs.microsoft.com/en-us/graph/query-parameters