question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] IQuotaByCounterKeysOperations.UpdateAsync fails

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vfedonkincommented, May 5, 2020

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 } }

0reactions
solankisamircommented, Jun 23, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my UpdateAsync(user) method fail the first time ...
UpdateAsync(user); fails with the exception: "There is no user with id: 99" (or whatever id value). However, if the user was previously logged ......
Read more >
Memory Store UpdateAsync: a lot of "Request Failed" errors
I have a function similar to this: repeat local Success, Errormessage = pcall(function() SMUsersOnline:UpdateAsync('UsersOnline', function(UsersOnline) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found