FATAL EXCEPTION: main Process: com.packagename, PID: 11371 java.lang.IllegalStateException: Cannot read raw response body of a converted body.
In retrofit, you can only ever read response.body() once, since it's a stream and it automatically closes once you call .string()
or when it auto-converts to whatever model class you have in Response<T>
return type. If you try to read twice, then you get the above error.
I need both the raw response string as well as the model class. What's the best way to do this? I do not want to make the API call twice. Is there some way to duplicate the response body? Ideally, I'd like to simply get String and T back with the response. That is, to not have to give up the generic type converter goodies that come with retrofit