Filtering users in AD B2C with graph service by postalCode not working

Cristi Stefan 41 Reputation points
2023-01-27T09:24:18.4433333+00:00

Hello,

I am trying to filter users by the postalCode field in an Azure's AD B2C using the graph service. I tried in two ways:

a) without advanced filters:

https://graph.microsoft.com/v1.0/users?$filter=postalCode eq 'qqq'

b) with the advanced query options:

https://graph.microsoft.com/v1.0/users?$count=true&$filter=postalCode eq 'qqq'

and the ConsistencyLevel: eventual set in the header.

This is the response I get with both attempts:

{
    "error": {
        "code": "Request_UnsupportedQuery",
        "message": "Unsupported or invalid query filter clause specified for property 'postalCode' of resource 'User'.",
        "innerError": {
            "date": "2023-01-26T15:46:53",
            "request-id": "",
            "client-request-id": ""
        }
    }
}

According to this page I found, the postalCode should be available for filtering: https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http#user-properties

Is there something that I am doing wrong? Did I misunderstand the docs?

Best regards, Cristi

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,583 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,465 questions
{count} votes

3 answers

Sort by: Most helpful
  1. JimmySalian-2011 41,916 Reputation points
    2023-01-27T13:03:50.8766667+00:00

    Hi,

    Did you tried adding Count? As per Microsoft - Specific usage of $filter and the $search query parameter is supported only when you use the ConsistencyLevel header set to eventual and $count.

    [https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0#properties

    Hope this helps.

    JS

    ==

    Please Accept the answer if the information helped you. This will help us and others in the community as well.


  2. Cristi Stefan 41 Reputation points
    2023-01-28T08:36:06.3266667+00:00

    Hello,

    I posted the same question in the Microsoft Docs / azure docs section on GitHub: https://github.com/MicrosoftDocs/azure-docs/issues/104335

    There is a note on the docs page https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http that specifies the fact that Advanced Query options cannot be used in AD B2C tenants. I missed this note unfortunately.

    The note below:

    Note

    • Using $filter and $orderBy together is supported only with advanced queries.
    • $expand is not currently supported with advanced queries.
    • The advanced query capabilities are currently not available for Azure AD B2C tenants.
    • To use advanced query capabilities in batch requests, specify the ConsistencyLevel header in the JSON body of the POST request.

    Closing the question now.

    Have a great day!

    0 comments No comments

  3. CarlZhao-MSFT 36,896 Reputation points
    2023-01-30T07:44:26.26+00:00

    Hi @Cristi Stefan

    Yes, filtering postalCode parameters is an advanced query, and advanced query capabilities are currently not available for Azure AD B2C tenants, which is what caused the issue.

    I recommend that you submit a user voice for this to add advanced query capabilities support for Azure AD B2C tenant in the near future, and I will vote for you to increase the priority of that request.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".