When I make a login request through Retrofit2 that succeeds, I get an empty body. However when the login fails for whatever reason, the response returns a JSON body like this: { message: "error message"}.
The issue is as follows, if I model the call like this:
interface LoginAPIService {
@POST("login")
fun login(@Body body: RequestBody): Call<LoginResponse>
}
I will get an EOF failure when the body returned is null, however if I model the call as:
interface LoginAPIService {
@POST("login")
fun login(@Body body: RequestBody): Call<Void>
}
then I will not receive the error message, which must be printed out for the user. Please suggest how to handle this odd case.