refit: Disable Refit from hiding HTTP content in case response code wasn't 200 (ApiException)
We use http code to indicate what’s wrong and send reason in json response. Currently Refit overrides this behavior with this message "Response status code does not indicate success: 400 (Bad Request)"
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (7 by maintainers)
By the way, with the above
GroupList
method, and assuming an error response like this:All you would have to do is:
You still get the automatic mapping for successful cases, and I don’t see how it adds much work when it fails. Can you explain why this isn’t enough, and more importantly - exactly how you see it working otherwise?
That’s all great, but this means I will change all my Refit from the elegant
to
Which kinda beats the purpose of Refit in the first place.
Let me share with you my implementation. I am using ASP.NET WebAPI, and I am enapsulating all my responses in a standard Json envelope:
Which the mobile has an identical one over. so my Refit is like:
and on mobile, I can easily check validity by doing
IMHO it should be possible to disable the Exception and offer a way to examine the response object including the Status code.