azure-sdk-for-java: [BUG] ConsumptionManager.usageDetails fails with 400 Bad Request
Simple request to get all usage details within a specified time range fails with 400 Bad Request.
Code snippet that reproduces the problem:
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-consumption</artifactId>
<version>1.0.0-beta.1</version>
</dependency>
ClientSecretCredential cred = new ClientSecretCredentialBuilder()
.tenantId("[tenantId]")
.clientId("[clientId]")
.clientSecret("[clientSecret]")
.build();
ConsumptionManager consumptionManager = ConsumptionManager.authenticate(cred, new AzureProfile(AzureEnvironment.AZURE));
String scope = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
String filter = "properties/usageStart ge '2021-07-01T00:00:00Z' and properties/usageEnd le '2021-07-01T23:59:59Z'";
List<UsageDetail> usageDetails = consumptionManager.usageDetails().list(
scope,
null, // expand
filter,
null, // skiptoken
null, // top
null, // metric
null // context
).stream().collect(Collectors.toList());
This issue can be reproduced only when the server returns 2 or more pages.
My investigation shows that filter parameter is not properly url_encoded for second page request.
I can also reproduce this issue for other methods that accept filter parameter: consumptionManager.marketplaces(), etc.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
@XiaofeiCao Seems they still have space in nextLink URL and it is malformed. Please add “service attention” label.
Also ping their release owner https://github.com/Azure/sdk-release-request/issues/2291
@XiaofeiCao Here you go