首页 > 解决方案 > Microsoft Graph API - 计算所有拥有许可证的用户

问题描述

我正在尝试查询 Graph 以获取所有具有特定许可证的用户。

我有以下数据: 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"
                }
            ]
        }
    ]
}

我的最终目标是计算拥有此许可证的所有用户:“c7df2760-2c81-4ef7-b578-5b5392b571df”,但作为开始,我试图获取所有这些用户的列表。

但是在拨打电话时: https ://graph.microsoft.com/v1.0/users ?$filter=assignedLicenses/any(a: a/skuId eq 'c7df2760-2c81-4ef7-b578-5b5392b571df')

我收到以下异常:

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

标签: microsoft-graph-api

解决方案


但是在拨打这个电话时:

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

我得到[一个]异常。

试试这个电话:

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

推荐阅读