Forecast cost Azure API Error code 400

Yuval Shpitzer 1 Reputation point
2021-11-07T08:51:23.5+00:00

I'm trying to get the Forecast cost of my Azure Subscription. To do this, I'm using what I found in this documentation:
Forecast - Usage.
I tried to use the TRY button in the documentation of Microsoft with this JSON:

{ type: "Usage", dataset: { "granularity": "monthly", "aggregation":{ "totalCost":{ "name":"Cost", "function":"Sum" } } }, timeframe: "MonthToDate" }

and I get ERROR 400 with this response:

{ "error":{ "code":"BadRequest", "message":"Invalid query definition: Invalid dataset grouping: 'BillingPeriod'; valid values: 'ResourceGroup','ResourceGroupName','ResourceType','ResourceId','ResourceLocation','SubscriptionId','SubscriptionName','MeterCategory','MeterSubcategory','Meter','ServiceFamily','UnitOfMeasure','PartNumber','BillingAccountName','BillingProfileId','BillingProfileName','InvoiceSection','InvoiceSectionId','InvoiceSectionName','Product','ResourceGuid','ChargeType','ServiceName','ProductOrderId','ProductOrderName','PublisherType','ReservationId','ReservationName','Frequency','InvoiceId','PricingModel','CostAllocationRuleName','MarkupRuleName','BillingMonth','Provider','BenefitId','BenefitName','CustomerTenantId','CustomerTenantDomainName','ResellerMPNId','PartnerEarnedCreditApplied','CustomerName','PartnerName',''.\r\n\r\n (Request ID: 16022d38-1857-4be5-a8cd-1b488325aa9b)" } }

What is the problem?

Thanks

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,047 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yuval Shpitzer 1 Reputation point
    2021-11-16T12:18:13.09+00:00

    Hi,
    Thank you for your answer.
    I would like to get the forecast cost of my subscription.
    I was tried to use the "TRY IT" button of your website - https://learn.microsoft.com/en-us/rest/api/cost-management/forecast/usage#code-try-0, and I was getting error 400.
    I have attached the photo of my try with console [f12].

    ![149773-image.png]1

    0 comments No comments