endsWith filter not supported?

孤者浪人 提交于 2021-02-11 14:18:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!