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