I am trying to get azure rate card details by following api in asp.net core application,

API:

https : //management.azure.com/subscriptions/{Sub Id}/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId eq 'MS-AZR-0044P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'

It was working earlier, but recently getting the below response,

Exception:

"System.Net.WebException: 'The remote server returned an error: (400) Authentication information is not given in the correct format. Check the value of Authorization header..'"

Please find my code below here, The same code was working properly in .net framework console.

Code:

string requestUrl = "https://management.azure.com/subscriptions/{Sub Id}/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId eq 'MS-AZR-0044P' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'"

string accessToken = "Auth token here";

var usageRequest = (HttpWebRequest)WebRequest.Create(requestUrl);

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

usageRequest.ContentType = "application/json";

var response = (HttpWebResponse)usageRequest.GetResponse();                                            

var receiveStreams = response.GetResponseStream();

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

var readData = readStreams.ReadToEnd();

Any ideas if anything changed on the Microsoft side or any another way to solve this exception ?

Regards,

Anand K

0

There are 0 answers