2

I am using retrofit 1.9 and i created logout method as

@GET("/user/logout")
void logoutUser(Callback<Response> callback);

logoutUser(new RequestCallback<Response>(this) {
    @Override
    public void success(Response response, Response response2) {
        settingsService.setUserLoggedOut();
        getMainActivity().finish();
    }
});

i upgraded it to retrofit 2.0 beta 4 and used this code

@GET("user/logout")
Call<Response> logoutUser();

logoutUser().enqueue(new RequestCallback<Response>(this) {
    @Override
    public void onResponse(Call<Response> call, Response<Response> response) {
        settingsService.setUserLoggedOut();
        getMainActivity().finish();
    }
});

I have this exception : java.lang.IllegalArgumentException: 'retrofit2.Response' is not a valid response body type. Did you mean ResponseBody?

what is the problem?

Ahmed Mohammed
  • 337
  • 3
  • 16

1 Answers1

5

I was able to overcome this by this answer: https://stackoverflow.com/a/33228322

So try:

@GET("user/logout")
Call<ResponseBody> logoutUser();

Where ResponseBody is an okhttp3.ResponseBody

and then

logoutUser().enqueue(new Callback<ResponseBody>() {

...

});
Community
  • 1
  • 1
shivgadhia
  • 66
  • 2
  • 2
    Is this the only option? What If I don't care about the response body. I just want a StatusCode 200 or 400 etc? – Zapnologica Jan 08 '17 at 18:58