Skip to content Skip to sidebar Skip to footer

Response In 202 Status In Retrofit2.0

i want to convert the Response in to JSON and show it to the User .I was able to display 200 response but in 202,i am failed. { Log.d(TAG, 'RESPONSE CODE' + respon

Solution 1:

try this:

StringsSignupResponse= gson.toJson(signUpResponse);

instead of

String sSignupResponse = gson.toJson(signUpResponse, SuccessResponse.class);

Solution 2:

200 (OK), 201(Created - when you insert something in server database) and 204(No content - server has processed your request and it don't return nothing instead) are corect. Check here for all response codes in HTTP/1.1

Solution 3:

You can take a look at RESTresponse code HERE

If responsecode is match with format 2xx, that means success. So, in you case you should check response.isSuccessful() to check if the response is success or not instead of check response code by manual

Solution 4:

I got an answer,Just do like this .You know upfront the 202 Response.So make a POJO class Response202.Now let SuccessResponse Class inherit the properties of Response Class.You are done now

SuccessResponseresponse202= response.body();
                        Gsongson202=newGson();
                        Stringjson202Str= gson202.toJson(response202, SuccessResponse.class);

Post a Comment for "Response In 202 Status In Retrofit2.0"