Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The same IdempotencyKey cannot return a custom error message #24

Open
apchenjun opened this issue Oct 20, 2021 · 3 comments
Open

The same IdempotencyKey cannot return a custom error message #24

apchenjun opened this issue Oct 20, 2021 · 3 comments

Comments

@apchenjun
Copy link

The first request can normally receive the returned custom format message
b5853d2d4c3640cbba64a2196f5b5c3
The second request cannot receive the custom format message
80bfb593fd5f531634c8f33693baef6
The second request with postman return 500
The first
f50258b8a1651a2204c168da36a9740
The second
8d89a1d02f6d3bfd53625184cfaa6e0

@apchenjun
Copy link
Author

apchenjun commented Oct 21, 2021

I hope the same IdempotencyKey throws an error and I can return a custom formatted error message
image
like this
image

@william-keller
Copy link

Hi @apchenjun

This error happened with me too

In my case, i am using swagger to generate openapi documentation

It occurs by a validation of swagger filter..

In your method or controller class you must add a (ProducessAtributte("application/json"))

Hope that it can help you

@ikyriak
Copy link
Owner

ikyriak commented Nov 6, 2021

Hello @apchenjun,

As @william-keller mentioned, the No output formatter was found for content types 'application/json; charset=utf-8, application/json; charset=utf-8' to write the response. warning is shown when we have not defined the Consumes and Produces media type.

Can you try to define it at your controller? For example, see the following sample code:

[ApiController]
[Route("[controller]")]
[Consumes("application/json")]
[Produces("application/json")]
[Idempotent(Enabled = true)]
public class SimpleController : ControllerBase
{
    // ...
}

In general, the concept of the library and Idempotency as described in the README file is to return the cached response (generated on the first try) in the subsequent requests (i.e., second, third, etc.) when using the same IdempotencyKey. That means that the actual code of the controller (action) will not be executed multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants