title: JAVA HttpPost enctype = "multiform/data"
body: <p>i'm trying to simulate a HttpPost request for form submission using <code>HttpClient 4.2.3</code></p>
  
  <p>the form is similar to</p>
  
  <pre><code>&lt;form action="localhost/xyz.aspx" method = "post" enctype="multipart/form-data"&gt;
       &lt;input type="text" name="name"&gt;
       &lt;input type="text" name="age"&gt;
       &lt;input type="text" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When i tried using java code like,</p>
  
  <pre><code> List&lt;NameValuePair&gt; formparams1 = new ArrayList&lt;NameValuePair&gt;();
   formparams1.add(new BasicNameValuePair("name","john"));
   formparams1.add(new BasicNameValuePair("age", "10"));
   UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams1);
   entity.setContentEncoding("multipart/form-data");
   entity.setContentType("multipart/form-data;boundary=--asd123");
  </code></pre>
  
  <p>i receive  <strong>HTTP Status 400 - java.lang.RuntimeException: Could find no Content-Disposition header within part</strong> </p>
  
  <p>Also i searched a while and tried another way,</p>
  
  <pre><code>MultipartEntity entity = new MultipartEntity();
  entity.addPart("name",new StringBody("john",Charset.forName("UTF-8")));
  entity.addPart("age", new StringBody("10",Charset.forName("UTF-8")));
  </code></pre>
  
  <p>Still i get an error like <strong>HTTP 415 HTTP 400</strong></p>
  
  <p>Could anyone pls help me in simulating such a request.</p>
  
  <p>TIA</p>