我正在使用 Microsoft Graph API,我想要实现的是将我办公地点的所有人员从 Azure AD 导入到我的个人联系人中。
使用 Graph Explorer我可以在 /users/
中找到自己使用 $filter
- 所以使用 https://graph.microsoft.com/v1.0/users?$filter=mail eq '<MyEmailAddress>'
.查看以下结果:
所以这个用户(我)有一个属性 officeLocation
这是我想要过滤的属性,以便让我的所有同事都在同一个办公室。因此我尝试了:
https://graph.microsoft.com/v1.0/users?$filter=officeLocation eq '<MyOfficeLocation>'
但是 - 我得到一个 Request_UnsupportedQuery
错误:
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'officeLocation' of resource 'User'.",
"innerError": {
"request-id": "407d5376-eeb4-46a5-8c93-c20e5b6b322e",
"date": "2017-07-13T15:26:49"
}
}
}
这是否意味着我不能过滤此属性?那将是相当不幸的。如果是这样 - 我可以应用任何解决方法吗?
最佳答案
$count 是这样工作的,甚至包括 $expand 和 $select 子句:
GET https://graph.microsoft.com/v1.0/users?$top=999&$count=true&$filter=startswith(officeLocation,'EU_')&$select=id,displayName&$expand=manager($select=id,mail,displayName;$levels=1)
ConsistencyLevel: eventual
在这里,我正在查询用户的 id、displayName 和他们的一级经理的一些详细信息(id、mail、displayName),其中用户的 officeLocation 以 'EU_' 开头
并且您必须在请求 header 中发送 ConsistencyLevel: eventual 才能使其正常工作..
关于microsoft-graph-api - 在 Graph API 中过滤 'officeLocation' 上的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45085237/