question

NavinDondapati avatar image
0 Votes"
NavinDondapati asked NavinDondapati answered

Azure COST API call via O365 login

Hi Guys,

We are using below cost api url to fetch data
https://management.azure.com/subscriptions/1313131`131313/resourceGroups/rg1/providers/Microsoft.CostManagement/query?api-version=2019-11-01

it works fine when use it below url
https://docs.microsoft.com/en-us/rest/api/cost-management/dimensions/list

But when we test in post man or other tools we receive below error
{
"error": {
"code": "AuthenticationFailed",
"message": "Authentication failed. The 'Authorization' header is missing."
}
}

We tried to pass user=xyz@zyz.com (company O365 id which has access to that resource group) and pwd=xyz in the body.

Regards,
Navin

azure-cost-management
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NavinDondapati - Thank you for your post!

You are making an ARM call here and so you need to pass in necessary authorization token in request header.. (just like any other ARM API call).
ARM will fail authentication if you are not. This is why the call is failing.


If the response helped, do "Accept Answer" and up-vote it.

0 Votes 0 ·

@NavinDondapati Thanks for the update. Glad to know you were able to resolve it.

0 Votes 0 ·
NavinDondapati avatar image
0 Votes"
NavinDondapati answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SadiqhAhmed-MSFT avatar image
0 Votes"
SadiqhAhmed-MSFT answered

@NavinDondapati - As mentioned, you need to pass the auth header in the request. The article below calls out options (using Postman)to authenticate to Azure Resource Manager.

Authenticate Postman against Azure Service Management API | Codit



If the response helped, do "Accept Answer" and up-vote it.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.