2

In Refit, is there anyway to get the raw HTTP response in ApiResponse object?

In my case, if response code is 200, it returns type Person. If the response code is 201, it returns with an Error response. I want to be able to deserialize the HTTP response content again if status code is 201.

I have read the following links, that's all to do with catch exception and do another deserialization. I'm already doing that in another case. But this case is different, there was no exception.

How to handle the exceptions

How to Handle Errors

Disable Refit from hiding HTTP content in case response code wasn't 200 (ApiException)

Thanks in advance

Jerry Ren
  • 41
  • 1
  • 6
  • actually, 201 is not an error code. We have 2xx --> sucesss, 3xx --> redirect, 4xx --> client error, 5xx --> server error – Võ Quang Hòa Jan 21 '20 at 13:08
  • @VõQuangHòa, thank you for your reply. Yes, 201 is not an error. That's what the other party defined. If response code is 201, it comes with error details in it. – Jerry Ren Jan 22 '20 at 01:59

1 Answers1

1

You can change the response type to HttpResponseMessage or string. See this section in Refit README

DonnyTian
  • 544
  • 4
  • 13