[BUG] IQuotaByCounterKeysOperations.UpdateAsync fails
See original GitHub issueDescribe the bug
I am trying to reset a quota on an API Management service using this function, but I am receiving an exception. See To Reproduce section for actual code.
Expected behavior
I would expect an HTTP 204 response and the quota to be reset.
Actual behavior
I receive an ErrorResponseException:
Operation returned an invalid status code 'BadRequest'
The actual response returned by the REST API is as follows:
{
"error": {
"code": "ValidationError",
"message": "Invalid payload format. Contract should have 'properties' specified.",
"details": null
}
}
After some investigation, the actual issue turns out to be a mismatch of the documented and actual behavior of this API call. In the documentation of the REST API and in the implementation of the library, the request is expected to look like this:
{
"callsCount": 0,
"kbTransferred": 0.0
}
This will lead to the aforementioned exception. The API will, however, accept a request like this:
{
"properties": {
"callsCount": 0,
"kbTransferred": 0.0
}
}
So either the documentation is wrong and thus the implementation of the library, or there is a bug in the REST API.
To Reproduce
await client.QuotaByCounterKeys.UpdateAsync(
resourceGroupName,
serviceName,
counterKey,
new QuotaCounterValueContractProperties(0, 0),
cancellationToken: cancellationToken);
Environment:
- I am using Microsoft.Azure.Management.ApiManagement version 5.0.0-preview
- The project is a .NET Core 3.1 application, see output of
dotnet --info
below
.NET Core SDK (reflecting any global.json):
Version: 3.1.201
Commit: b1768b4ae7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.201\
Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Yes, it’s a bug in documentation/sdk client. I will fix it.
The correct request should have properties as { “properties”: { “callsCount”: 0, “kbTransferred”: 0.0 } }
@dzsibi The NuGet is now released. Please try it. https://www.nuget.org/packages/Microsoft.Azure.Management.ApiManagement/6.0.0-preview @markcowl we can close this issue.