Call URL x times where x is in the JSON response after the first call
Instead of a for loop, consider a do {} while (pageCount &lt;= numberOfPages)
loop and use an increment operator inside the loop. For this to work though both pageCount and numberOfPages need to have scoping outside of the loop, ie instantiated before the do{ } statement. 

do{ } while () loops are guaranteed to run once, then perform the test in the while () to check if they continue. while( ){ } loops perform the check, then run until a value of false is found.  

    int number = 1;
    int expectedNumber;
    do {
      HttpEntity&lt;String&gt; requestEntity = new HttpEntity&lt;String&gt;(getBody(number), getHeader());
      ResponseEntity&lt;Stuff&gt; responseEntity =
          HttpClient.getInstance().getClient()
              .exchange(uri, HttpMethod.POST, requestEntity, Stuff.class);
      Stuff response = responseEntity.getBody();
      // do stuff with response here.
      expectedNumber = (int) response.getPaginationResponse().getTotalPages();
      number++;
    } while (number &lt;= expectedNumber &amp;&amp; expectedNumber &gt; 0);