用户的 Microsoft Graph Api $count 响应不一致 [英] Inconsistent Microsoft Graph Api $count response for users
问题描述
我正在尝试通过我的 B2C AAD 租户通过 Microsoft Graph API 获取用户总数,但响应似乎出错或省略了 @odata.count
属性.
网上的反馈也是褒贬不一,有些人说 $count
仍然不受支持,即使官方文档说/users 支持 $count
.
你也可以参考这个文档.
请在 Microsoft Graph 反馈论坛中提出功能请求 以便产品团队将来可以将此功能添加到 b2c 租户中.
I'm trying to get a total count of users through Microsoft Graph API through my B2C AAD tenant, but the response seems to either error out or is omitting the @odata.count
property.
Feedback online is also mixed where some people say that $count
is still unsupported even thought the official documentation says that $count
is supported for /users.
https://docs.microsoft.com/en-us/graph/query-parameters#count-parameter
I tried through the graph api online version: https://developer.microsoft.com/en-us/graph/graph-explorer?request=users?$count=true&method=GET&version=v1.0
With this result:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"@odata.count": 31,
"value": [
...
]
}
However doing the same thing through something like postman nets me this result:
GET /v1.0/users?$count=true HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer [token]
ConsistencyLevel: eventual
{
"error": {
"code": "Request_BadRequest",
"message": "This request is not supported by the service",
"innerError": {
"date": "2020-10-09T18:19:44",
"request-id": "4d97fd77-19ad-42f9-9357-66c24c867ce2",
"client-request-id": "4d97fd77-19ad-42f9-9357-66c24c867ce2"
}
}
}
If I remove ConsistencyLevel
header, I get a valid response but there is no @odata.count
property.
Is there some Graph Api permissions that I am missing, or is this expected?
For the B2C tenant the user count is not yet supported for this /users endpoint. But for a general Azure AD tenant it will give you the count when you follow these below steps.
- Select the beta endpoint. (
https://graph.microsoft.com/beta/users?$count=true
) - Add $count=true in the QueryString.
- Add
ConsistencyLevel = eventual
to the Request headers.
You will see the results as below.
You can also refer this Document.
Please raise a feature request in the Microsoft Graph Feedback Forum so that the product team may add this feature to b2c tenant in future.
这篇关于用户的 Microsoft Graph Api $count 响应不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!