Search code examples
c#microsoft-graph-apimicrosoft-graph-sdks

Graph API filtering users by specific attribute


I'm using the C# Graph API SDK

I have a specific attribute that is formatted like this

extension_{appID}_{attribute}

I want to return only users who have values with this attribute

I've done this but its not supported. I was wondering if there is another way this could be done.

graphServiceClient.Users.Request()
.Filter("extension_{appID}_{attribute} ne null")
.GetAsync();

Solution

  • Try to add ConsistencyLevel header (code for SDK v4)

    var options = new List<QueryOption> 
    { 
        new QueryOption("$count", "true") 
    }; 
    
    var result = graphServiceClient.Users
                    .Request(options)
                    .Filter("extension_{appID}_{attribute} ne null")
                    .Header("ConsistencyLevel", "eventual")
                    .GetAsync();
    

    Documentation:

    Advanced queries - user properties