[英]Microsoft Graph API query failing with provided filter
在我的 .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
我在我的租户中尝试过同样的方法,并且有效。 在我的例子中,扩展属性鞋码是一个字符串。 你能确认你的扩展属性的类型吗? 并尝试使用 type = string 的扩展属性?
https://graph.microsoft.com/v1.0/users?$select=extension_d09380e2b4c642b9a203fb816a04a7ad_ShoeSize&$filter=extension_d09380e2b4c642b9a203fb816a04a7ad_ShoeSize eq '12'
你也可以试试 AADGraph ( https://graphexplorer.azurewebsites.net )
https://graph.windows.net/myorganization/users?$select=extension_d09380e2b4c642b9a203fb816a04a7ad_ShoeSize&$filter=extension_d09380e2b4c642b9a203fb816a04a7ad_ShoeSize eq 'abhi'
请让我知道这对你有没有用。
目前,您仍然需要将旧版 Azure AD Graph API 与 AAD B2C 结合使用。 从B2C 文档:
必须使用Azure AD Graph API来管理 Azure AD B2C 目录中的用户。 这与 Microsoft Graph API 不同。 在此处了解更多信息。
虽然在许多情况下您可以使用 Microsoft Graph 来对抗 AAD B2C,但您会更频繁地或不会被此类问题绊倒。 除非你特别需要 Microsoft Graph 的功能,否则我会避免使用它,直到它得到正式支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.