Posts

Showing posts with the label retrofit

How to set a priority of retrofit requests

How to set a priority of retrofit requests I have ViewPager and in this ViewPager there are 4 fragments. Sorry but I can't to add a code, because that would be very big. Each of my fragments on create does asynchronous retrofit request to server. I have access_token and refresh_token too. So when my access_token expires I need to do a call using refresh_token to update my access_token . So when I launch my application it opens viewPager with my 4 fragments doing asynchronous requests. That means 4 requests at a time. And when my access_token is expired and I'm launching my app, all the fragments try to update the access token using refresh token. Turns out that one fragment updates the access_token (after the update refresh_token changes) other fragments try to update the token too, but I'm getting 401 because 1 fragment already updated the token and other fragments try to update the access_token using old refresh token. ViewPager access_token refresh_token access_tok...

How to capture raw/plain text response from the server

Image
How to capture raw/plain text response from the server I'm currently using Retrofit 1 I'm trying to find away to capture raw/plaintext response from server but not sure how to retrieve it. This where i initialize it @POST(ApplicationConstants.USER_URL+"/resendActivationEmail") void resendEmail(@Body String email, ResponseCallback result); and here's where i implement it. userServiceApi.resendEmail(email, new ResponseCallback() { @Override public void success(Response response) { LogHelper.debug(""); } @Override public void failure(RetrofitError error) { LogHelper.debug(error.getMessage); } }); what i get from error.getMessage is only the http code status. if i try to test the api with postman, this will be the response that i capture in JSON format and this one ...

multiple api request using retrofit and rx java

multiple api request using retrofit and rx java I am new to android and I have a scenario where I want to get get data from multiple api. Let suppose api_a , api_b , api_c , api_d . These api are independent of each other but I want to show data from these api in a mix Recycler View ( horizontal and vertical ). So I want to make these api call in such a manner so that I can get every api data at a time so that i can display in recycler view. I already using retrofit 2 but for that I had to chain them one by one which is very lengthy and I think this is not a feasible approach. I know little bit about RX JAVA ,but I only know how to make one request at a time. Please help Try the accepted answer - stackoverflow.com/questions/36401193/… – Sanchita Santra Jun 30 at 10:39 suppose the result ...

Java : Android : Retrofit 2 response code is 200, response.body is null

Java : Android : Retrofit 2 response code is 200, response.body is null I am trying to build an Android App that implements a Collaborative Filtering Algorithm using Retrofit 2,Realm and The Movie Database API. When making my Retrofit callback, onResponse returns a successful status code (200), but from logging I get that my response.body().getResults returns null. I'm in this pickle now and I can't get it to work.My ApiService seem to be working fine and I make other retrofit callbacks to get directors,movies by title,movies by release date.Anyways, here is some code snippets that might be helpful. APIService.java package com.yannis.thesis.movierecommendationapp.api; import com.yannis.thesis.movierecommendationapp.models.DirectorResponse; import com.yannis.thesis.movierecommendationapp.models.GenreResponse; import com.yannis.thesis.movierecommendationapp.models.Movie; import com.yannis.thesis.movierecommendationapp.models.MovieResponse; import com.yannis.thesis.movierecommenda...