title: Posting Dynamic values as a request body
body: <p>I am fetching the ID from some other API hitting the endpoint of that API.
  I am fetching Dynamic ID from that API.
  Now, In this code I which have posted I should send a request body that should accept dynamic ID that I am fetching from other API which I am storing in <strong>str</strong> and Iterate till the length of the ID and get JSON response for each ID.</p>
  
  <pre><code>   for(int i=0;i&lt;array.length();i++) 
     {         
     str.add(array.getJSONObject(i).getString("id"));
     }
     for(String s:str)
     {
      HttpPost request1 = new HttpPost("/2.0/clusters/events");
      //StringEntity params=new StringEntity(array[i]);
  
      ***StringEntity params =new StringEntity("{\"id\":\"+s+\"}");*** 
      //main concern to send dynamic ID as a body  
  
      request1.addHeader("Authorization",bearerToken);
      request1.addHeader("content-type", "application/json");          
      request1.addHeader("Accept","application/json");
      request1.setEntity(params);
      System.out.println(params);
      HttpResponse response1 = httpClient.execute(request1);
      System.out.println("Response Code:" + 
      response1.getStatusLine().getStatusCode());
      String json1 = EntityUtils.toString(response1.getEntity());
      System.out.println(json1);
      JSONObject event = new JSONObject(json1);
      JSONArray arrays=event.getJSONArray("events");
      for (int k=0;k&lt; arrays.length();k++){
      JSONObject ids = arrays.getJSONObject(k);
      System.out.println(ids.get("id").toString()); 
      System.out.println(ids.get("timestamp").toString()); 
      System.out.println(ids.get("type").toString()); 
      System.out.println(ids.get("details").toString()); 
      }
      }
  </code></pre>
  
  <p><strong>The main question is how to send an value dynamically as a request body using String Entity or any other using JAVA.</strong>
  I should fetch the ID and Its repose for each ID till its length.</p>