title: How to call External API in for loop
body: <p>I try to call API with different id as shown in following code. But it only executed for first run and stop. Can Anyone help how to solve this problem?   </p>
  
  <p>The size of the idArray is 2. </p>
  
  <pre><code>for (int i = 0; i&lt; idArray.size(); i++){
          String id = idArray.get(i);
          Thread.currentThread().sleep(3000);
          String myURI1 = "https://api.bulksms.com/v1/messages/"+id;
          URL url1 = new URL(myURI1);
          System.out.println(myURI1);
          HttpURLConnection request1 = (HttpURLConnection) url1.openConnection();
          request1.setDoOutput(true);
          request1.setRequestProperty("Authorization", "Basic " + authEncoded);
          request1.setRequestMethod("GET");
          request1.setRequestProperty( "Content-Type", "application/json"); 
          BufferedReader in1 = new BufferedReader( new InputStreamReader(request1.getInputStream()));
          String inputLine1;
          StringBuffer response1 = new StringBuffer();
          while ((inputLine1 = in1.readLine()) != null) {
              response1.append(inputLine1);
          }
  }
  </code></pre>