.net - Microsoft Graph API 查询因提供的筛选器而失败
问题描述
在我的 .NET 应用程序中,我正在尝试使用 Microsoft Graph API 从 Azure AD B2C 获取用户。我还想根据自定义用户属性过滤这些用户。
我已经建立了这个网址
https://graph.microsoft.com/v1.0/users?$select=extension_{Id}_lastUpdatedDate&$filter=extension_{Id}_lastUpdatedDate eq '2019-08-10'
这会返回 400 错误,extension_{Id}_lastUpdatedDate
说不存在
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Property 'extension_{Id}_lastUpdatedDate' does not exist as a declared property or extension property.",
"innerError": {
"request-id": "a925b2f4-fef8-47a1-b644-9b2e652f1746",
"date": "2019-09-13T14:14:00"
}
}
}
但是,当我发送完全相同的请求时,除了查询的过滤器部分,就像这样
https://graph.microsoft.com/v1.0/users?$select=extension_{Id}_lastUpdatedDate
我收到 200 的结果,听起来该字段存在并且为 AD 中的所有用户正确填写
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(extension_{Id}_lastUpdatedDate)",
"value": [
{"extension_{Id}_lastUpdatedDate": "2018-07-12T14:31:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-05-30T14:28:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-06-30T14:28:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-07-30T14:28:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-08-30T14:28:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-07-12T14:31:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-07-30T14:31:47.208Z"},
{"extension_{Id}_lastUpdatedDate": "2018-07-30T14:31:47.208Z"}
]
}
有谁知道这里发生了什么?如果我看到选择查询中的字段,错误消息所说的内容对我来说几乎是不可能的。
解决方案
我遇到了同样的问题。API 在 $filter 函数中区分大小写,但在 $select 函数中不区分大小写。因此,请确保您的 $filter 具有区分大小写的正确名称。
这不起作用:
https://graph.microsoft.com/v1.0/users?$select=extension_{id}_tenantId,displayName&$filter=extension_{id}_tenantId eq 1
这有效:
https://graph.microsoft.com/v1.0/users?$select=extension_{id}_tenantId,displayName&$filter=extension_{id}_TenantId eq 1
推荐阅读
- shell - 如何以安全的方式在 Jenkins shell 脚本中传递密码?
- php - 获取所有行在列中有值
- amazon-web-services - 如何保持多个实例之间的文件同步?这样只有一个实例会拾取文件并处理它
- javascript - 为什么我的 JS 对象作为未定义值添加到数组中?
- shell - 如何在 groovy 脚本的 shell 块中声明一个新变量?
- html - 使用内联 CSS 为标签内的标签设置样式
- c - 插入排序的过程
- .net - xml 转换定位器匹配未按预期工作
- spring - Spring mvc 将相同的 url 重定向到不同的主机
- java - getter 在设置后无法访问它的值