I keep getting the above error when try to sort the list on displayName, however sorting is clearly supported according the example below: https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=csharp#request-3
I tried adding ConsistencyLevel headers and count query param with no luck.
var users = await GraphHelper.client.Users
.Request() //new List<QueryOption>() { new QueryOption("$count","true") }
.Header("ConsistencyLevel", "eventual")
.Filter($"accountEnabled eq true and extension_{AppConfig.variable["B2C:ExtensionId"]}_BankId eq '{bankId}'")
.OrderBy("displayName")
.Select($"id,displayName,identities,extension_{AppConfig.variable["B2C:ExtensionId"]}_BankId").GetAsync();

Same query works in graph explorer but not in the REST API.

I suspect that you are seeing this discrepancy because of incorrect setup in POSTMAN and code.
You can setup POSTMAN by following this step-by-step guide. A quick glance of steps is below:
Similarly, please check similar setup of C# code as well.
It seems there are some rules that we need to follow while using filter and orderby:

Hence, when I followed the rules and ran https://graph.microsoft.com/beta/users?$count=true&$filter=startsWith(displayName,'B')&$orderby=displayName desc query, it works:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With