reportRoot:getM365AppUserCounts
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
获取一个报告,其中提供了组织中每个应用的活动用户数趋势, (Outlook、Word、Excel、PowerPoint、OneNote 和 Teams) 。
注意: 有关不同报表视图和名称的详细信息,请参阅管理中心中的 Microsoft 365 报表 - Microsoft 365 应用版使用情况 。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
✅
权限
为此 API 选择标记为最低特权的权限。 只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
Reports.Read.All
不可用。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用
Reports.Read.All
不可用。
注意: 要使委托权限允许应用代表用户读取服务使用情况报告,租户管理员必须向用户分配适当的Microsoft Entra ID受限管理员角色。 有关更多详细信息,请参阅授权 API 读取 Microsoft 365 使用情况报告 。
HTTP 请求
GET /reports/getM365AppUserCounts(period='{period_value}')
函数参数
在请求 URL 中,提供以下参数的有效值。
参数
类型
说明
period
string
指定在多长时间内聚合报表。 {period_value} 支持的值为: D7
、 D30
、 D90
和 D180
。 这些值采用格式 Dn ,其中 n 表示在多少天内聚合报表。 必需。
可选的查询参数
此方法支持 $format
OData 查询参数 来自定义响应。 默认输出类型为 text/csv
。 但是,如果要指定输出类型,可以使用 OData $format
查询参数将默认输出设置为 text/csv
或 application/json
。
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
请求正文
请勿为此方法提供请求正文。
响应
CSV
如果成功,此方法返回 302 Found
响应,以重定向到报表的预先验证的下载 URL。 可以在响应的 Location
头中找到此 URL。
预先验证的下载 URL 的有效时间很短(几分钟),不需要 Authorization
标头。
CSV 文件包含下面的列标题:
报表刷新日期
报表周期
报表日期
Outlook
Word
Excel
PowerPoint
OneNote
Teams
JSON
如果成功,此方法在 200 OK
响应正文中返回响应代码和 JSON 对象。
示例
示例 1:CSV 输出
下面是输出 CSV 的示例。
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/beta/reports/getM365AppUserCounts(period='D7')?$format=text/csv
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Reports.GetM365AppUserCountsWithPeriod("{period}").GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Format = "text/csv";
});
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta reports get-m365-app-user-counts-with-period get --period {period-id}
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphreports "github.com/microsoftgraph/msgraph-beta-sdk-go/reports"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestFormat := "text/csv"
requestParameters := &graphreports.ReportsGetM365AppUserCounts(period='{period}')RequestBuilderGetQueryParameters{
Format: &requestFormat,
}
configuration := &graphreports.ReportsGetM365AppUserCounts(period='{period}')RequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
period := "{period}"
graphClient.Reports().GetM365AppUserCountsWithPeriod(&period).Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.reports().getM365AppUserCountsWithPeriod("{period}").get(requestConfiguration -> {
requestConfiguration.queryParameters.format = "text/csv";
});
const options = {
authProvider,
};
const client = Client.init(options);
let stream = await client.api('/reports/getM365AppUserCounts(period='D7')')
.version('beta')
.get();
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Reports\GetM365AppUserCounts(period='{period}')\GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration();
$queryParameters = GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->format = "text/csv";
$requestConfiguration->queryParameters = $queryParameters;
$graphServiceClient->reports()->getM365AppUserCountsWithPeriod('{period}', )->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Reports
Get-MgBetaReportM365AppUserCount -Format "text/csv" -Period $periodId
from msgraph import GraphServiceClient
from msgraph.generated.reports.get_m365_app_user_counts(period='{period}').get_m365_app_user_counts_with_period_request_builder import GetM365AppUserCountsWithPeriodRequestBuilder
graph_client = GraphServiceClient(credentials, scopes)
query_params = GetM365AppUserCountsWithPeriodRequestBuilder.GetM365AppUserCountsWithPeriodRequestBuilderGetQueryParameters(
format = "text/csv",
)
request_configuration = GetM365AppUserCountsWithPeriodRequestBuilder.GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
await graph_client.reports.get_m365_app_user_counts_with_period("{period}").get(request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
HTTP/1.1 302 Found
Content-Type: text/plain
Location: https://reports.office.com/data/download/JDFKdf2_eJXKS034dbc7e0t__XDe
执行 302 重定向,下载的 CSV 文件将采用以下架构。
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Report Refresh Date,Report Period,Report Date,Outlook,Word,Excel,PowerPoint,OneNote,Teams
示例 2:JSON 输出
下面是返回 JSON 的示例。
请求
以下示例显示了一个请求。
GET https://graph.microsoft.com/beta/reports/getM365AppUserCounts(period='D7')?$format=application/json
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Reports.GetM365AppUserCountsWithPeriod("{period}").GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Format = "application/json";
});
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta reports get-m365-app-user-counts-with-period get --period {period-id}
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphreports "github.com/microsoftgraph/msgraph-beta-sdk-go/reports"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestFormat := "application/json"
requestParameters := &graphreports.ReportsGetM365AppUserCounts(period='{period}')RequestBuilderGetQueryParameters{
Format: &requestFormat,
}
configuration := &graphreports.ReportsGetM365AppUserCounts(period='{period}')RequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
period := "{period}"
graphClient.Reports().GetM365AppUserCountsWithPeriod(&period).Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.reports().getM365AppUserCountsWithPeriod("{period}").get(requestConfiguration -> {
requestConfiguration.queryParameters.format = "application/json";
});
const options = {
authProvider,
};
const client = Client.init(options);
let stream = await client.api('/reports/getM365AppUserCounts(period='D7')')
.version('beta')
.get();
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Reports\GetM365AppUserCounts(period='{period}')\GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration();
$queryParameters = GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->format = "application/json";
$requestConfiguration->queryParameters = $queryParameters;
$graphServiceClient->reports()->getM365AppUserCountsWithPeriod('{period}', )->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Reports
Get-MgBetaReportM365AppUserCount -Format "application/json" -Period $periodId
from msgraph import GraphServiceClient
from msgraph.generated.reports.get_m365_app_user_counts(period='{period}').get_m365_app_user_counts_with_period_request_builder import GetM365AppUserCountsWithPeriodRequestBuilder
graph_client = GraphServiceClient(credentials, scopes)
query_params = GetM365AppUserCountsWithPeriodRequestBuilder.GetM365AppUserCountsWithPeriodRequestBuilderGetQueryParameters(
format = "application/json",
)
request_configuration = GetM365AppUserCountsWithPeriodRequestBuilder.GetM365AppUserCountsWithPeriodRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
await graph_client.reports.get_m365_app_user_counts_with_period("{period}").get(request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 188
{
"value": [
{
"reportRefreshDate": "2020-06-30",
"reportPeriod": 7,
"userCounts": [
{
"reportDate": "2020-06-30",
"outlook": 1513,
"word": 911,
"excel": 790,
"powerPoint": 683,
"oneNote": 969,
"teams": 1532
}
]
}
]
}