命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
获取一个报表,该报表提供组织中每个平台(Windows、Mac、Web 和移动)的所有应用中活动用户的趋势。
注意: 有关不同报表视图和名称的详细信息,请参阅 Microsoft 365 报表 - Microsoft 365 应用版使用情况。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
Reports.Read.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用 |
Reports.Read.All |
注意: 对于允许应用代表用户读取服务使用情况报告的委派权限,租户管理员必须为用户分配相应的 Azure AD 受限管理员角色。 有关详细信息,请参阅 授权 API 读取 Microsoft 365 使用情况报告。
HTTP 请求
GET /reports/getM365AppPlatformUserCounts(period='{period_value}')
函数参数
在请求 URL 中,提供以下参数的有效值。
| 参数 |
类型 |
说明 |
| period |
string |
指定在多长时间内聚合报表。 {period_value} 支持的值为: D7、 和 D90``D30``D180. 这些值采用格式 D n,其中 n 表示在多少天内聚合报表。 必需。 |
可选的查询参数
此方法支持使用 $format OData 查询参数自定义响应。 默认输出类型为 text/csv。 但是,如果要指定输出类型,可以使用 OData $format 查询参数将默认输出设置为 text/csv 或 application/json。
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
请求正文
请勿为此方法提供请求正文。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和 Edm.Stream 对象。
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/getM365AppPlatformUserCounts(period='D7')?$format=text/csv
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var stream = await graphClient.Reports
.GetM365AppPlatformUserCounts("D7")
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let stream = await client.api('/reports/getM365AppPlatformUserCounts(period='D7')')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/reports/getM365AppPlatformUserCounts(period='D7')?$format=text/csv"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphStream *stream = [[MSGraphStream alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
InputStream stream = graphClient.customRequest("/reports/getM365AppPlatformUserCounts(period='D7')", InputStream.class)
.buildRequest()
.get();
响应
下面展示了示例响应。
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,Windows,Mac,Mobile,Web
示例 2:JSON 输出
下面是返回 JSON 的示例。
请求
下面展示了示例请求。
GET https://graph.microsoft.com/beta/reports/getM365AppPlatformUserCounts(period='D7')?$format=application/json
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var stream = await graphClient.Reports
.GetM365AppPlatformUserCounts("D7")
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let stream = await client.api('/reports/getM365AppPlatformUserCounts(period='D7')')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/reports/getM365AppPlatformUserCounts(period='D7')?$format=application/json"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphStream *stream = [[MSGraphStream alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
InputStream stream = graphClient.customRequest("/reports/getM365AppPlatformUserCounts(period='D7')", InputStream.class)
.buildRequest()
.get();
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 156
{
"value": [
{
"reportRefreshDate": "2020-06-30",
"reportPeriod": 7,
"userCounts": [
{
"reportDate": "2020-06-30",
"windows": 1445,
"mac": 146,
"mobile": 1131,
"web": 1080
}
]
}
]
}