title: How to make Java HttpPost NOT include url in body
body: <p>We have some old java code that POSTs some fields and values to a dotnet5 web api - The api is having problems dealing with the body of the POST as it includes the url/uri as the first part of the body.</p>
  <p>The Java sends: <code>http://127.0.0.1:5555?producerRef=GREEN&amp;systemId=78&amp;status=false</code></p>
  <p>But the api is expecting something like: <code>producerRef=GREEN&amp;systemId=78&amp;status=false</code>
  as per <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#example" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#example</a>. If we send a test message via Postman then the api has no problems.</p>
  <p>This is the Java code:</p>
  <pre><code>List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(queryParams.size());
  for (Map.Entry&lt;String, String&gt; entry : queryParams.entrySet()) {
      params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
  }
  // the address is just that, there's NO parameters 
  HttpPost post = new HttpPost(this.cmAddress.toURI());
  post.setEntity(new UrlEncodedFormEntity(params, &quot;UTF-8&quot;));
  post.setHeader(HttpHeaders.CONTENT_TYPE, &quot;application/x-www-form-urlencoded&quot;);
  CloseableHttpResponse response = httpClient.execute(post);
  </code></pre>
  <p>It's quite simple, but always adds the url to the start of the body of the request. If this is the only way to produce this, what could I do to produce something that looks like this: <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#example" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#example</a></p>
  <p>Many Thanks.</p>