简体   繁体   中英

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. I am able to filter using the givenName using the startsWith() function but not able to search with mobile/postal code.

My request is 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.

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. 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

The note's text is below: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM