mailboxUsageDetailsRequest returns 异常

mailboxUsageDetailsRequest returns exception

正在用 Microsoft.Graph V1.12.0 替换 MSOnline cmdlet。

报告mailboxUsageDetailsReport = null; IReportRootGetMailboxUsageDetailRequestBuilder mailboxUsageDetailsRequestBuilder = null; IReportRootGetMailboxUsageDetailRequest mailboxUsageDetailsRequest = null;

mailboxUsageDetailsRequestBuilder = graphServiceClient.Reports.GetMailboxUsageDetail(期间); mailboxUsageDetailsRequest = mailboxUsageDetailsRequestBuilder.Request(); mailboxUsageDetailsReport = await mailboxUsageDetailsRequest.GetAsync();

最后一行抛出:

Newtonsoft.Json.JsonReaderException
  HResult=0x80131500
  Message=Unexpected character encountered while parsing value: R. Path '', line 0, position 0.
  Source=Newtonsoft.Json

Fiddler 显示带有正确文件的 302 响应 "Location" 但响应正文仅包含 0,

解决方法是

HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Get, mailboxUsageDetailsRequest.RequestUrl); 等待 graphClient.AuthenticationProvider.AuthenticateRequestAsync(hrm); HttpResponseMessage 响应 = 等待 graphClient.HttpProvider.SendAsync(hrm);

Microsoft Graph .Net 客户端 v1.12.0 当前不支持报表 API 以第一种 class 方式。您正在分享建议的解决方法,我们感谢您分享。响应是一个 csv 文件,这就是您看到 JsonReaderException 的原因。