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

nabi04 56 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.
10,836 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,868 questions
{count} votes

Accepted answer
  1. CarlZhao-MSFT 37,786 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.

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Siddharth Gautam 855 Reputation points
    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.
    0 comments No comments