title: HttpPost write body as well as the request parameters
body: <p>I am using Apache's <a href="https://hc.apache.org/httpcomponents-client-4.5.x/httpclient/apidocs/org/apache/http/client/methods/HttpPost.html" rel="nofollow">HttpPost</a>. I am trying to upload files to the web server and it results in following:</p>
  
  <blockquote>
    <p>POST site/upload?uploadType=chunked&amp;requestId={requestId} HTTP/1.1</p>
    
    <p>Host: 
    
    <p>Accept: application/xml</p>
    
    <p>Authtoken: 
    
    <p>Request Parameters</p>
    
    <p>requestId  The unique identifier for the current upload session.</p>
    
    <p>Request Headers</p>
    
    <p>Host   The host name of the web server.</p>
    
    <p>Accept     The format of the response. Valid values are: application/xml or application/json.</p>
    
    <p>Authtoken  The authentication token received after successfully logging on.</p>
    
    <p>FileEOF    Specifies whether the end of file has reached with the current file chunk. Allowed values are 0 and 1. End of file means value 1.</p>
    
    <p>Request Body</p>
    
    <p>Include the contents of the file chunk in bytes.</p>
  </blockquote>
  
  <p>What I have come up is this:</p>
  
  <pre><code>HttpPost post = new HttpPost(url);
              post.setHeader("Authtoken", params.get("token"));
              String fileName = file.getName();
              long offset = Long.parseLong(chunkOffset);
              //...
              post.setHeader("FileEOF", eof);
              /*List&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();
              postParameters.add(new BasicNameValuePair("requestId", requestId));
              post.setEntity(new UrlEncodedFormEntity(postParameters));*/
  
              fileInputStream.skip(offset);
              fileInputStream.read(bytes);
              post.setEntity(new ByteArrayEntity(bytes));
  </code></pre>
  
  <p>Where do I write the parameters for the HttpPost around here?</p>