Home > front end >  Filter on onPremisesExtensionAttributes
Filter on onPremisesExtensionAttributes

Time:12-29

Iam trying to make Make a GET request to the /users endpoint, using the filter parameter to specify the onPremisesExtensionAttributes value:

var users = await graphClient.Users
.Request()
.Filter($"onPremisesExtensionAttributes/{extensionAttributeName} eq '{extensionAttributeValue}'")
.GetAsync();

but i got error "Microsoft.Graph.ServiceException: 'Code: Request_UnsupportedQuery Message: Unsupported or invalid query filter clause specified for property 'extensionAttribute14' of resource 'User'."

i can get the uers onPremisesExtensionAttributes values and filter works fine with other parameters like department of givenName but only show error with onPremisesExtensionAttributes

I had searched alot abut this problem and advanced querties for azure Ad on "https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=csharp"

CodePudding user response:

To make it work you need to add query parameter $count with value true and the header ConsistencyLevel:eventual

List<Option> requestOptions = new List<Option>();
requestOptions.Add(new QueryOption("$count", "true"));
requestOptions.Add(new HeaderOption("ConsistencyLevel", "eventual"));

var users = await graphClient.Users
    .Request(requestOptions)
    .Filter($"onPremisesExtensionAttributes/{extensionAttributeName} eq '{extensionAttributeValue}'")
    .GetAsync();
  • Related