laloune
laloune

Reputation: 673

endsWith filter not supported?

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 ?

Upvotes: 0

Views: 3415

Answers (2)

GJBisschop
GJBisschop

Reputation: 345

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://learn.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)

Upvotes: 1

Carl Zhao
Carl Zhao

Reputation: 9549

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.

Upvotes: 2

Related Questions