title: How to use OkHttp for multiple request to similar links in Android
body: <p>I'm trying to follow the example at the <a href="http://square.github.io/okhttp/" rel="nofollow">official documentation of OkHttp</a> and I have no problem when posting 1 request, but <strong>if the REST API I need to get info from has many different pages I can't make it work for different pages</strong> for example, <strong>theMovieDB API</strong> has 5 pages for all filmography of Tom Hanks which are:</p>
  
  <p><a href="http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=1" rel="nofollow">http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=1</a></p>
  
  <p><a href="http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=2" rel="nofollow">http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=2</a></p>
  
  <p>...</p>
  
  <p><a href="http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=5" rel="nofollow">http://api.themoviedb.org/3/discover/movie?with_cast=31&amp;sort_by=release_date.asc&amp;api_key=deea9711e0770caae3fc592b028bb17e&amp;page=5</a> </p>
  
  <p>So I tried this approach without success: </p>
  
  <pre><code>public class ActorFilmographyActivity extends AppCompatActivity {
  
      public static final String TAG = ActorFilmographyActivity.class.getSimpleName();
  
      private int totalPages = 5; //this is set at runtime with another OkHTTP call, lets say is five for simplicity
  
      OkHttpClient client = new OkHttpClient();
      private List&lt;String&gt; JSONs = new ArrayList&lt;&gt;();
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_actor_filmography);
  
          for (int pageNum=1; pageNum &lt;= 4; pageNum++){
                  try {
                      getResponseFor(pageNum);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
          }
  
              for (String string : JSONs){
                  Log.v(TAG, string);
              }
          }
      }
  
  //This is the method I'm trying to use for multiple requests:
  
      private void getResponseFor(int pageNum) throws IOException {
  
          String url = "http://api.themoviedb.org/3/discover/movie?with_cast="
                  + actor.getId() + "&amp;sort_by=release_date.asc&amp;api_key=" + API_KEY + "&amp;page=" + pageNum;
  
          Request request = new Request.Builder()
                  .url(url)
                  .build();
  
          Call call = client.newCall(request);
  
          call.enqueue(new Callback() {
              @Override
              public void onFailure(Request request, IOException e) {
  
              }
  
              @Override
              public void onResponse(Response response) throws IOException {
                  JSONs.add(response.body().string());
              }
          });
  </code></pre>
  
  <p>How can I use OKHTTP for multiple request in android?</p>