Issue:
I am retrieving Group Members using Microsoft Graph API. I need to order the results based on the 'displayName'. Doing this on its own, works fine. I also need to know whether the members returned potentially has any of its own members. I therefore add the expand (members) to my OData query. The expand works, but the original orderBy then fails to order.
It seems that you can use Expand and Orderby on the 'Groups' call, but not on the 'Members' call.
Graph Explorer:
Works:
Only Orderby on Group Members:
https://graph.microsoft.com/v1.0/groups/{groupId}/members/microsoft.graph.group?$orderby=displayName
Expand & Orderby on Only Groups:
https://graph.microsoft.com/v1.0/groups?$expand=memberOf($filter=not memberOf/any())&$orderby=displayName
**With the request header: ConsistencyLevel: eventual
Doesn't work:
Expand & Orderby on Group Members:
https://graph.microsoft.com/v1.0/groups/{groupId}/members/microsoft.graph.group?$orderby=displayName&$expand=members
Documentation:
I can't seem to find anywhere where the documentation flags this as an issue. The closest I could find was the "Known Issues" page stating that "$expand: No support for @odata.nextLink. No support for more than 1 level of expand. No support with extra parameters ($filter, $select)."
https://learn.microsoft.com/en-us/graph/known-issues?view=graph-rest-1.0#query-parameter-limitations
These only flag filter and select... Also, this does not explain why I can use Expand, Filter and OrderBy all combined with the Groups call, but not with the Members call
Other notes:
I've been testing using both Microsoft Graph Explorer as well as the .Net SDK (version 3.25 and latest 4.0). Both of these give the same issue.
**Also: There is an existing open bug for the .NetSDK that does not allow casting to a Group when doing the Members call. I do not have an issue with this and am currently using a workaround:
https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/836