用 Microsoft.Graph V1.12.0 替换 MSOnline cmdlet。
报告邮箱UsageDetailsReport = null; IReportRootGetMailboxUsageDetailRequestBuilder 邮箱UsageDetailsRequestBuilder = null; IReportRootGetMailboxUsageDetailRequest 邮箱UsageDetailsRequest = null;
mailboxUsageDetailsRequestBuilder = graphServiceClient.Reports.GetMailboxUsageDetail(期间); 邮箱UsageDetailsRequest = 邮箱UsageDetailsRequestBuilder.Request(); 邮箱UsageDetailsReport = 等待邮箱UsageDetailsRequest.GetAsync();
最后一行抛出:
Newtonsoft.Json.JsonReaderException
HResult=0x80131500
Message=Unexpected character encountered while parsing value: R. Path '', line 0, position 0.
Source=Newtonsoft.Json
Fiddler 使用正确的文件“位置”显示 302 响应,但响应正文仅包含 0,
解决方法是
HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Get, mailboxUsageDetailsRequest.RequestUrl); 等待 graphClient.AuthenticationProvider.AuthenticateRequestAsync(hrm); HttpResponseMessage 响应 = 等待 graphClient.HttpProvider.SendAsync(hrm);