Share via

Credit API does not work

Bruce Lei 0 Reputation points
2024-01-03T23:12:51.5666667+00:00

https://learn.microsoft.com/en-us/rest/api/consumption/credits/get?view=rest-consumption-2023-05-01&tabs=HTTP

for this api, we try to input our billingAccountId and billingProfileId, it does not work and response 400.

I do not understand what's the reason. Can you test it and verify it's working? I get the billingAccountId and billingProfileId from billing data.

{
  "error": {
    "code": "400",
    "message": "The request could not be understood. Parameter BillingAccountId: 7c8b2c72-6f7b-5ab9-32ca-ac6369786b48 is in a format that could not be processed with this version (Request ID: 51fec54c-4502-4c08-a27b-3a2dea728a8e)"
  }
}
Cost Management
Cost Management

A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Sadiqh Ahmed 49,571 Reputation points Microsoft External Staff Moderator
    2024-01-08T20:06:28.2066667+00:00

    @Bruce Lei Appreciate your patience in this matter!

    If I am not wrong, billing account ID for MCA should look like this: f4f0d3a8-21fd-5f80-c025-1d27a2011b7c:0cb40ac7-36f4-4888-a058-ad3c4f2cd876_2019-05-31 

    Simply go to Cost Management + Billing, click into the Billing Account for MCA, and go to Properties, you can directly copy from there. The one that you are using now is just CRID. 

    Let me know if you could have a try and if that works with this kind of format.


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

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2024-01-03T23:12:51.57+00:00

    Based on the context provided, it seems that the API endpoint you are trying to use is for the Consumption API, which is not supported for checking Azure credit balance for a billing account under Microsoft Customer Agreement. Instead, you can use the Azure Billing and the Consumption APIs to programmatically get the credit balance for your billing account. The examples shown below use REST APIs. Currently, PowerShell and Azure CLI are not supported.

    To check the Azure credit balance for your billing account, you need to use the following API endpoint:

    https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingProfiles/{billingProfileId}/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/balance?api-version=2021-08-01-preview
    

    Please replace {billingAccountId}, {billingProfileId}, and {enrollmentAccountId} with the appropriate values.

    If you are viewing Azure credits at the billing account scope and the billing account has more than one billing profile, the Azure credits page will show a table with a summary of Azure credits for each billing profile. Select a billing profile from the list, select payment methods and then Azure credits to view details for a billing profile.

    To get the credit balance for your billing account, you can make a GET request to the above API endpoint. The API response returns estimated and current balance for the billing profile. The following elements are returned in the API response:

    • estimatedBalance: The estimated amount of credits you have after considering all billed and pending transactions.
    • currentBalance: The amount of credits as of your last invoice. It doesn't include any pending transactions.
    • pendingCreditAdjustments: The adjustments like refunds that are not yet invoiced.
    • expiredCredit: The credit that expired since your last invoice.
    • pendingEligibleCharges: The credit eligible charges that are not yet invoiced.

    Please note that you must have an owner, contributor, reader, or invoice manager role on the billing profile or owner, contributor, or reader role on the billing account to view Azure credit balance for a billing profile. To learn more about the roles, see Understand Microsoft Customer Agreement administrative roles in Azure.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.