I'm trying to get a list of users with a certain license using the Microsoft Graph API. This can be tested using Graph Explorer .
This is a cropped example of what is returned for one user:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#users/$entity",
"id": "69615b5e-8b26-430c-ae89-4e626f5ba240",
"accountEnabled": true,
"assignedLicenses": [
{
"disabledPlans": [],
"skuId": "f8a1db68-be16-40ed-86d5-cb42ce701560"
},
{
"disabledPlans": [],
"skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
}
]
}
I want to get a list of all users that have an assigned license with skuId
of "f8a1db68-be16-40ed-86d5-cb42ce701560"
This is what I've tried so far:
https://graph.microsoft.com/beta/users?$filter=AssignedLicenses/any(a:a/SkuId eq 'f8a1db68-be16-40ed-86d5-cb42ce701560')
Gives me the error:
A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.
https://graph.microsoft.com/beta/users?$filter=AssignedLicenses/any(a:a/SkuId eq f8a1db68-be16-40ed-86d5-cb42ce701560)
Gives me the error:
')' or ',' expected at position 42 in 'assignedLicenses/any(a:a/skuId eq f8a1db68-be16-40ed-86d5-cb42ce701560)'.
https://graph.microsoft.com/beta/users?$filter=AssignedLicenses/any(a:a/SkuId eq cast('f8a1db68-be16-40ed-86d5-cb42ce701560',Edm.Guid))
Give me the error:
The child type 'Edm.Guid' in a cast was not an entity type. Casts can only be performed on entity types.
This SO post suggests that my first try would work but it doesn't. Am I doing something wrong or is it just not possible to filter by license assignment?