使用过滤器查询用户并在不支持的查询中扩展结果
Query users with a filter and expand results in unsupported query
我正在尝试从 Microsoft Graph API 中获取用户列表。
许多用户没有电子邮件地址,这些用户是我不需要的系统用户。
所以我的查询看起来像 /users?$filter=mail ne null
对于另一个概述,我需要显示每个用户的经理,所以我尝试添加 &$expand=manager
。但这样做会导致 Unsupported Query
。
当我删除 filter
参数时,它确实起作用了。
我如何才能在单个查询中只获取相关用户及其经理?
可选地,我希望仅从管理员那里接收 ID,作为一种优化。我只需要 ID,因为我已经获取了所有用户及其数据。 /users?$expand=manager($select=id)
是我正在尝试的,但我收到错误 Invalid $select properties.
如果要在$expand
内使用$select
到select个别经理的属性,需要$levels参数,例如expand=manager($levels=max;$select=id)
。更多详情请参考here
例如
https://graph.microsoft.com/v1.0/users?$expand=manager($levels=max;$select=id)
更新
如果我们想在 $filter 查询参数上使用不等于 (ne) 运算符,我们必须将 ConsistencyLevel header 设置为 eventual
并且,除了 $search,
使用 $count
查询参数(作为 URL 段或 $count=true 查询字符串)。详情请参考here
例如
https://graph.microsoft.com/v1.0/users?$filter=mail ne null&&$expand=manager($levels=1;$select=id)&$count=true
我正在尝试从 Microsoft Graph API 中获取用户列表。
许多用户没有电子邮件地址,这些用户是我不需要的系统用户。
所以我的查询看起来像 /users?$filter=mail ne null
对于另一个概述,我需要显示每个用户的经理,所以我尝试添加 &$expand=manager
。但这样做会导致 Unsupported Query
。
当我删除 filter
参数时,它确实起作用了。
我如何才能在单个查询中只获取相关用户及其经理?
可选地,我希望仅从管理员那里接收 ID,作为一种优化。我只需要 ID,因为我已经获取了所有用户及其数据。 /users?$expand=manager($select=id)
是我正在尝试的,但我收到错误 Invalid $select properties.
如果要在$expand
内使用$select
到select个别经理的属性,需要$levels参数,例如expand=manager($levels=max;$select=id)
。更多详情请参考here
例如
https://graph.microsoft.com/v1.0/users?$expand=manager($levels=max;$select=id)
更新
如果我们想在 $filter 查询参数上使用不等于 (ne) 运算符,我们必须将 ConsistencyLevel header 设置为 eventual
并且,除了 $search,
使用 $count
查询参数(作为 URL 段或 $count=true 查询字符串)。详情请参考here
例如
https://graph.microsoft.com/v1.0/users?$filter=mail ne null&&$expand=manager($levels=1;$select=id)&$count=true