android - java.lang.IllegalArgumentException: 'retrofit2.Response' is not a valid response body type. Did you mean ResponseBody? -


my question similar retrofit 2.0 beta 4 response illegalargumentexception answer didn't me.

i'm migrating retrofit 1.9 2.0.2. i'm registering app messaging once launches.

    /**      * synchronous method register gcm token on backend server      *      * @return true, in case of success response, false otherwise.      */     public boolean registergcmtoken()     {         ...          try         {             call<response> call = mservice.registergcmtoken(sessionid, this.additional_query);             final response response = call.execute().body(); // <<< error points here             final defaultresponse defaultresponse = defaultresponse.newinstance(response);             return defaultresponse.issuccess();         }         catch (ioexception ignored)         {          }          return false;     } 

my interface looks like:

    @get("my/url")     call<response> registergcmtoken(@header(constant.header_wildcard) string accesstoken,                     @querymap map<string, string> additionalquery); 

once launch app i'm getting error:

java.lang.illegalargumentexception: 'retrofit2.response' not valid response body type. did mean responsebody?

and points line mentioned above.

my newinstance method looks like:

    public static final defaultresponse newinstance(final response response)     {         final defaultresponse defaultresponse = new defaultresponse();         if (response != null)         {             defaultresponse.status = response.code();         }          return defaultresponse;     } 

so see, need know http status code. changing response generic responsebody i'm not able http status code. so, recommendation? thanks

what got while reading answers post suggested instead of :

@get("my/url")     call<response> registergcmtoken(@header(constant.header_wildcard) string accesstoken,                     @querymap map<string, string> additionalquery); 

try :

@get("my/url")     call<responsebody> registergcmtoken(@header(constant.header_wildcard) string accesstoken,                     @querymap map<string, string> additionalquery); 

because getting responsebody , not response here :

        final response response = call.execute().body(); 

like did : how can handle empty response body retrofit 2?


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -