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

Serialization based on response status code #832

Closed
mweel1 opened this issue Jul 26, 2024 · 1 comment
Closed

Serialization based on response status code #832

mweel1 opened this issue Jul 26, 2024 · 1 comment

Comments

@mweel1
Copy link

mweel1 commented Jul 26, 2024

A common use case is that you send a request to the API and it comes back with an 400 status and a difference type of JSON then you might have expected with say a 200.

What do you think about adding functionality that would allow us to do something like

.WhenStatus(400)
   .ReceiveJson<ValidationResponse>();
@mweel1 mweel1 changed the title Serilazation based on status code Serialization based on response status code Jul 26, 2024
@tmenier
Copy link
Owner

tmenier commented Aug 2, 2024

If that's part of the same fluent call chain as when you specify a different type for 200 responses, then what's the overall return type of the call? Task<object>? I think it would have to be, because the actual return type can't be known at runtime.

There's already 3 patterns for handing error responses: try/catch, inspecting FlurlResponse, and handling OnError. I'm not sure we need to introduce another way.

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

No branches or pull requests

2 participants