要获取价目表,我正在使用api。
https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId+eq+{offer-id}+and+Currency+eq+'USD'+and+Locale+eq+'en-US'+and+RegionInfo+eq+'IN'
我在请求中传递了授权标题,其值为“Bearer eyioe ...”。 它工作得比较早,但最近收到了以下回复
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>InvalidAuthenticationInfo</Code>
<Message>Authentication information is not given in the correct format. Check the value of Authorization header.
RequestId:5dc4ea49-b01e-00f9-6760-dcfb83000000
Time:2018-04-25T06:42:45.8106146Z</Message>
</Error>
答案 0 :(得分:0)
可能的情况是,RateCard API正在发回302重定向。在本期问题发布时,这个版本在新版本中发生了变化。
建议的解决方法是:
const string subId = "Subscription Id here";
const string token = "Auth Token here.";
const string offer = "MS-AZR-0003P";
const string currency = "USD";
const string locale = "en-US";
const string region = "US";
using (var rateCardClient = new HttpClient() { BaseAddress = new Uri("https://management.azure.com/") })
{
rateCardClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
var response = await rateCardClient.GetAsync($"subscriptions/{subId}/providers/Microsoft.Commerce/RateCard?api-version=2016-08-31-preview&$filter=OfferDurableId eq '{offer}' and Currency eq '{currency}' and Locale eq '{locale}' and RegionInfo eq '{region}'");
Console.WriteLine($"StatusCode:{response.StatusCode}");
var ratecard = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
Console.Write(ratecard);
}
有关详细信息,请参阅此Github问题页面: https://github.com/MicrosoftDocs/azure-docs/issues/7423