Azure资源使用api的数据请求失败

时间:2017-01-10 10:15:19

标签: azure azure-billing-api

使用资源使用Api计算资源消耗成本。 有时会发生异常

  

“请求的数据尚未处理。请在5中重试   分“

使用的代码:

string usageUrl = String.Format("{0}/{1}/{2}/{3}", "https://management.azure.com","subscriptions", subscriptionId, "providers/Microsoft.Commerce/UsageAggregates?api-version=2015-06-01-preview&reportedstartTime=" + startDate + "T09%3a00%3a00%2b00%3a00&reportedEndTime=" + endDate + "T" + endTime + "%3a00%3a00%2b00%3a00&aggregationGranularity=Hourly&showDetails=true");

HttpWebRequest usageRequest = (HttpWebRequest)WebRequest.Create(usageUrl);

usageRequest.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + accessToken);

usageRequest.ContentType = "application/json";

HttpWebResponse responses = (HttpWebResponse)usageRequest.GetResponse();

Stream receiveStreams = responses.GetResponseStream();

StreamReader readStreams = new StreamReader(receiveStreams, Encoding.UTF8);

var usageResponse = readStreams.ReadToEnd();
  

输入:

     

startDate - 2017-01-07,

     

endDate - 2017-01-10,

     

结束时间 - 09(小时)。

     

当前UTC日期 - 2017-01-10(yyyy-MM-dd)

     

当前UTC时间 - 09:15:25(hh:mm:ss)

格式没问题。如果endTime作为“08”传递,则此代码可以正常工作。

0 个答案:

没有答案