问题
following:
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'P')
works like a charm, whereas
https://graph.microsoft.com/v1.0/users?$filter=endsWith(displayName,'z')
throws a 400 error
Any idea why endsWith is not supported ?
回答1:
Comment moved to answer:
This is a question that has been asked. Although UserVoice has voted a lot, it still does not support filters such as "endswith". see:here.
回答2:
Unfortunately this is still not working for displayName. But for mail and userPrincipalName the following works (since recently).
Graph explorer:
https://graph.microsoft.com/v1.0//users?$count=true&$filter=endsWith(userPrincipalName,'@example.com')&$select=id,userPrincipalName
Graph.NET SDK:
var request = graphServiceClient.Users
.Request()
.Header("ConsistencyLevel", "eventual")
.Filter("endswith(userPrincipalName,'@example.com')")
.Select(x => new { x.Id, x.UserPrincipalName })
.OrderBy("userPrincipalName");
request.QueryOptions.Add(new QueryOption("$count", "true"));
var result = await request.GetAsync();
See also example 5 at https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=csharp (at this moment the C# example in the docs is incomplete)
来源:https://stackoverflow.com/questions/64983320/endswith-filter-not-supported