0
votes

I'm trying to query Graph to get all users that have a specific license.

I have the following data: https://graph.microsoft.com/v1.0/users?$select=id,assignedLicenses

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,assignedLicenses)",
    "value": [
        {
            "id": "6e7b768e-07e2-4810-8459-485f84f8f204",
            "assignedLicenses": []
        },
        {
            "id": "87d349ed-44d7-43e1-9a83-5f2406dee5bd",
            "assignedLicenses": [
                {
                    "disabledPlans": [],
                    "skuId": "c7df2760-2c81-4ef7-b578-5b5392b571df"
                }
            ]
        },
        {
            "id": "5bde3e51-d13b-4db1-9948-fe4b109d11a7",
            "assignedLicenses": [
                {
                    "disabledPlans": [],
                    "skuId": "90d8b3f8-712e-4f7b-aa1e-62e7ae6cbe96"
                },
                {
                    "disabledPlans": [],
                    "skuId": "725422ed-e205-400e-ab0a-3899d8a398ca"
                },
                {
                    "disabledPlans": [],
                    "skuId": "c7df2760-2c81-4ef7-b578-5b5392b571df"
                }
            ]
        }
    ]
}

My end goal will be to count all users with this license: "c7df2760-2c81-4ef7-b578-5b5392b571df" but as a start i'm trying to just get a list with all these users.

But when making this call: https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/any(a: a/skuId eq 'c7df2760-2c81-4ef7-b578-5b5392b571df')

i'm getting the following exception:

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid filter clause",
        "innerError": {
            "request-id": "9a4837b1-cbcf-4c0b-a54e-168959aeb4d8",
            "date": "2019-08-12T07:47:12"
        }
    }
}
1

1 Answers

0
votes

But when making this call:

https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/any(a: a/skuId eq 'c7df2760-2c81-4ef7-b578-5b5392b571df')

I'm getting [an] exception.

Try this call instead:

https://graph.microsoft.com/v1.0/users?$top=999&$filter=assignedLicenses/any(x:x/skuId eq c7df2760-2c81-4ef7-b578-5b5392b571df)