Open whaakman opened 3 years ago
Thank you for creating the issue! One of our team members will get back to you shortly with additional information. If this is a product issue, please close this and contact the particular product's support instead (see https://support.microsoft.com/allproducts for the list of support websites).
@whaakman Please move this issue to https://github.com/MicrosoftDocs/azure-docs/issues
Describe the bug The samples as provided at https://docs.microsoft.com/en-us/rest/api/cost-management/query/usage are incorrectly formatted and result in errors.
To Reproduce I’m using API Calls to get information from Azure Cost Management. I’m doing this by using the query API (Microsoft.CostManagement/query). If I go with the sample of the API (Billing Account query – modern / Query - Usage (Azure Cost Management) | Microsoft Docs) then I am presented with the following sample:
{ "type": "Usage", "timeframe": "MonthToDate", "dataset": { "granularity": "Daily", "filter": { "and": [ { "or": [ { "dimension": { "name": "ResourceLocation", "operator": "In", "values": [ "East US", "West Europe" ] } }, { "tag": { "name": "Environment", "operator": "In", "values": [ "UAT", "Prod" ] } } ] }, { "dimension": { "name": "ResourceGroup", "operator": "In", "values": [ "API" ] } } ] } } }
This sample has multiple problems and will result in an error similar to the following: { "error": { "code": "BadRequest", "message": "Invalid query definition: Invalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\nInvalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\nInvalid dataset filter; on a QueryFilter one and only one of and/or/not/dimension/tag can be set.\r\n\r\n (Request ID: 4c5ea6e1-a94e-4c9e-a61d-ec0b502b8627)" } }
This can be resolved by refactoring the body into the following. Some key differences here:
Regards, Wesley