如何通过 userType = null 过滤用户?用户、userType、null

2023-09-07 09:06:21 作者:只有影子伴我成长ゝ

I am trying to filter out Guest users in my Graph query. Since the ne comparison operator is not supported I was trying $filter=userType eq 'Member' or userType eq null instead. That fails too though. Any known workarounds to list users with null as userType?

Without that I need to download about a million rows each time and throw 4 out of 5 away on the client side, which is pretty slow and wasteful.

{
"error": {
    "code": "Request_UnsupportedQuery",
    "message": "Unsupported or invalid query filter clause specified for property 'userType' of resource 'User'.",
    "innerError": {
        "request-id": "411f7927-c3af-4042-a619-eee1c88971a0",
        "date": "2018-03-17T18:28:35"
    }
}
Mysql中要注意的地方,不等于 会过滤掉null的情况

解决方案

Update as of June 2021

the ne comparison operator is now supported on userType on graph! So you can now get users that are not guest users with this query: https://graph.microsoft.com/v1.0/users/$count?$filter=userType ne 'guest'

here is a link to graph explorer with that query