[英]Filter (searching) on Microsoft Azure (graph) API
I would like to query the Microsoft Azure AD by passing either a mobile number or a postal code.我想通过传递手机号码或邮政编码来查询 Microsoft Azure AD。 I am able to filter using the
givenName
using the startsWith()
function but not able to search with mobile/postal code.我可以使用
startsWith()
function 使用givenName
进行过滤,但无法使用手机/邮政编码进行搜索。
My request is users?$filter=postalCode%20eq%20'560036'&api-version=1.6
我的要求是
users?$filter=postalCode%20eq%20'560036'&api-version=1.6
and getting the response:并得到回应:
{
"odata.error": {
"code": "Request_UnsupportedQuery",
"message": {
"lang": "en",
"value": "Unsupported or invalid query filter clause specified for property 'postalCode' of resource 'User'."
}
}
}
According to this old post in Microsoft Developer you can add OR clause to filter more than one field if you use startsWith() function. 根据Microsoft Developer中的这篇旧帖子 ,如果使用startsWith()函数,可以添加OR子句来过滤多个字段。
users?$filter=startswith(postalCode, '560036') OR startswith(mobileNumber, '123456')
Of course, you still have to encode equal sign, parenthesis and spaces 当然,您仍然需要编码等号,括号和空格
My issue was that I was trying this on an Azure AD B2C tenant.我的问题是我在 Azure AD B2C租户上尝试这个。 This is not supported on this type of tenant.
此类租户不支持此功能。 I've missed the note in the docs about this: https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http
我错过了文档中关于此的注释: https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.