Not able to get Azure Billing Account Id

Viewed 1151

I need to get Usage Details at Billing Account Scope for that firstly I used this API but It returns an empty value. I used the Bearer Access token for hitting this API.Is anything other than this am I missed?

Postman Request attached as screenshot

Postman Request attached as screenshot

2 Answers

I believe you're using the wrong API. To get Billing info you must provide billing account name:

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}?api-version=2019-10-01-preview

https://docs.microsoft.com/en-us/rest/api/billing/2019-10-01-preview/billingaccounts/get

PS: you can use the "try it" and test if it will return the information you need.

You can also query usage API and use one of the available dimensions to get cost related info:

POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2019-11-01

https://docs.microsoft.com/en-us/rest/api/cost-management/query/usage

This api will return a value if account belongs to Modern billing

Related