Reputation: 245
I have a Microsoft Graph user with the following property:
"onPremisesExtensionAttributes": {
"extensionAttribute1": "attr1",
"extensionAttribute2": null,
"extensionAttribute3": null,
"extensionAttribute4": null,
etc.
},
I can't seem to find any documentation or examples on how to filter against this property. I've tried:
https://graph.microsoft.com/beta/users?$filter=extensionAttribute1 eq 'attr1'
https://graph.microsoft.com/beta/users?$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1'
https://graph.microsoft.com/beta/users?$filter=onPremisesExtensionAttributes/any(x:startswith(x,'attr1'))
All of them result in a Bad Request, so clearly something is wrong.
"code": "BadRequest",
"message": "Invalid filter clause",
QUESTION: how do you format a filter against onPremisesExtensionAttributes or any other property that contains a list of named properties (e.g. extensionAttribute1...n)? For a list of strings (e.g. proxyAddresses) you can just do:
$filter=proxyAddresses/any(x:startswith(x,%27smtp:myemail%27))
Upvotes: 10
Views: 8253
Reputation: 1
Nice it works If y are using powershell and ms graph api (google howto toke works)
$headers = @{
"Authorization" = "Bearer $token"
"ConsistencyLevel" = "eventual"
}
# API Endpoint
$uri = "https://graph.microsoft.com/v1.0/users?`$count=true&`$select=displayName,id,department,jobtitle,extensions&`$filter=(onPremisesExtensionAttributes/extensionAttribute1 eq 'VALUE')"
# Make the API call
try {
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get
} catch {
Write-Host "Some Error";
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
Continue
}
Upvotes: 0
Reputation: 1652
You can now filter on the onPremisesExtensionAttributes
:
https://graph.microsoft.com/v1.0/users?$count=true&$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1'
Two important points to note:
ConsistencyLevel
HTTP request header to eventual
. Otherwise you’ll get a 400
status code back with the following message Property 'extensionAttribute1' does not exist as a declared property or extension property.
$count=true
even if you don’t care about the count, otherwise you’ll get a 400
status code back with the following message Property 'extensionAttribute1' does not exist as a declared property or extension property.
Upvotes: 13