$expand sometimes does not return all the data

Elad Solomon 1 Reputation point
2022-09-20T14:11:04.477+00:00

Hi all

I work with Microsoft Graph 1.0 and I have a strange issue.

When I run the this API call:
https://graph.microsoft.com/v1.0/users/**<UserID>**?$select=mail%2CgivenName%2Csurname%2Cmail%2CbusinessPhones%2Cid%2CaccountEnabled%2CcompanyName%2Ccountry%2Cdepartment%2CofficeLocation%2CuserPrincipalName%2CusageLocation%2CgivenName%2Csurname&$expand=memberof($select=groupTypes%2CdisplayName)

I get only 11 groups under the $expand=memberof even though this user is a member of 29 groups.

I am aware of the limitation with this query parameter($expand) of 'Returns a maximum of 20 objects' and so I wonder why 11 and not 20?

note: I use the same API call and get the real number of groups of other users(the problem is for one specific user)

Please advise,
Thanks.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,814 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,716 Reputation points Microsoft Vendor
    2022-09-20T14:45:14.05+00:00

    Hi @Elad Solomon ,

    This is a known limitation of $expand:Returns a maximum of 20 objects., you have to look at alternatives and work with direct GET /users/{id}/memberOf API.
    Are you get the same result of 11 groups or the total 29 groups, when using GET /users/{id}/memberOf?

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra 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.