How to query users with extension attribute excluding NULL in graph api?

user0808 46 Reputation points
2023-03-02T03:54:19.2133333+00:00

I want to query users in my tenant with the extension attribute but excluding users with the blank/null value for that extension. Currently this is my query:

https://graph.microsoft.com/v1.0/users?$select=id,givenName,surname,extension_---------&$filter=contains(extension-----_----)

But I keep getting this error:

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid filter clause",
        "innerError": {
            "date": "2023-03-02T03:52:23",
            "request-id": "ada4bb9b-75c3-4daa-b8ae-85c4d21fe51a",
            "client-request-id": "96211638-62e7-b6c8-3678-d65123d14178"
        }
    }
}

Can anyone help me to get the right query? Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
870 questions
Microsoft Graph Users API
Microsoft Graph Users API
A Microsoft API that allows you to build compelling app experiences based on users, their relationships with other users and groups, and the resources they access for example their mails, calendars, files, administrative roles, group memberships.
641 questions
{count} votes

Accepted answer
  1. CarlZhao-MSFT 20,776 Reputation points
    2023-03-02T10:27:55.7966667+00:00

    Hi @user0808

    According to my test, the existing graph $filter query parameter cannot complete your context requirement, because the advanced query capabilities are currently not available for Azure AD B2C tenants.

    User's image

    I suggest you get the user collection and then filter locally.

    Hope this helps.

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

    1 person found this answer helpful.
    No comments

1 additional answer

Sort by: Most helpful
  1. SiddharthGautam-MSFT 775 Reputation points Microsoft Vendor
    2023-03-02T11:40:00.5933333+00:00

    Hello user0808,

    Thanks for posting!

    Currently $filter query parameter does not support for Open extension attribute. Please refer the below screenshot:

    User's image

    Reference link for the same.

    The following table shows support for $filter by extension properties on the user object.

    User's image

    Reference link for the same.

    Hope this helps.

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

    1 person found this answer helpful.
    No comments