title: Apache http post example
body: <p>I am very new to this Apache http client. I have an URL to make a webservice call to one of the service. I was successfully executed with the GET request but I am trying to execute this with the POST request but I am not getting any response. I was unable to get the content from the entity.</p>
  
  <p>My URL: "<a href="https://maps.googleapis.com/maps/api/place/details/xml?reference=CoQBcQAAAEZ7yCju-0lhU7sZIBBe_On9jYImWzZ9Zt5rIg1tX6zaH02dHrQMHF1LFHY1_yUuXzsUf6m6-rrQJ8Ec_mGxBYtV85Wyb4anakaUi3QuZj7ygJXB3Fd5x69k_4UnDKMmEBNa410vbCXgQOGIkHCbNpcbC8ENxmVlUrqiifmdfuLgEhCtPATMhFRdsjuyAL_j__OEGhTnqujRRMYy_5-kxzcqCdMY4_1dbA&amp;sensor=true&amp;key=key1" rel="nofollow">https://maps.googleapis.com/maps/api/place/details/xml?reference=CoQBcQAAAEZ7yCju-0lhU7sZIBBe_On9jYImWzZ9Zt5rIg1tX6zaH02dHrQMHF1LFHY1_yUuXzsUf6m6-rrQJ8Ec_mGxBYtV85Wyb4anakaUi3QuZj7ygJXB3Fd5x69k_4UnDKMmEBNa410vbCXgQOGIkHCbNpcbC8ENxmVlUrqiifmdfuLgEhCtPATMhFRdsjuyAL_j__OEGhTnqujRRMYy_5-kxzcqCdMY4_1dbA&amp;sensor=true&amp;key=key1</a>";</p>
  
  <p>This was executed with the GET method. Below u can see my code.</p>
  
  <pre><code>public class HttpClientPostExample {
  public static void main(String[] args) throws ClientProtocolException,
          IOException {
      String url = "https://maps.googleapis.com/maps/api/place/details/xml?";
  
      HttpClient client = HttpClientBuilder.create().build();
      // HttpRequest httpRequest = HttpsClientImpl.createRequest("Post", url);
      HttpPost httpPost = new HttpPost(url);
  
      List&lt;NameValuePair&gt; nameValuePairList = new ArrayList&lt;NameValuePair&gt;();
      nameValuePairList
              .add(new BasicNameValuePair(
                      "reference",
                      "CoQBcQAAAEZ7yCju-0lhU7sZIBBe_On9jYImWzZ9Zt5rIg1tX6zaH02dHrQMHF1LFHY1_yUuXzsUf6m6-rrQJ8Ec_mGxBYtV85Wyb4anakaUi3QuZj7ygJXB3Fd5x69k_4UnDKMmEBNa410vbCXgQOGIkHCbNpcbC8ENxmVlUrqiifmdfuLgEhCtPATMhFRdsjuyAL_j__OEGhTnqujRRMYy_5-kxzcqCdMY4_1dbA"));
      nameValuePairList.add(new BasicNameValuePair("sensor", "true"));
      nameValuePairList.add(new BasicNameValuePair("key",
              "AIzaSyBA0Hu3is9qIJ5v6NEuofigk0y-aQwqiP0"));
      httpPost.addHeader("User-Agent", "User-Agent");
      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
      HttpResponse response = client.execute(httpPost);
      System.out.println(response.getStatusLine().getStatusCode());
  
      Header[] headerArray = response.getAllHeaders();
      for (Header header : headerArray) {
          System.out.println("Header Name: " + header.getName()
                  + " Header Value: " + header.getValue());
      }
  }
  </code></pre>
  
  <p>Can any one help me on this. Is this the right approach to make a POST request...???</p>
  
  <p>How can I get actual URL before firing/calling the execute method...???</p>