I am trying to post some data to a server but not getting results as expected. I get 200 OK response but the returned html source has a string saying "Error - 404 Page not found"
I think I'm doing something wrong with the set of data that I'm sending. Maybe I'm missing something as I never worked with multiform data before.
Here is the multiform data that is sent over(I've used tamper data to check what is sent over
POSTDATA =-----------------------------124853047628807
Content-Disposition: form-data; name="mgnlModelExecutionUUID"
4ee01e05-dc16-4535-a222-693b98ec9b69
-----------------------------124853047628807
Content-Disposition: form-data; name="field"
-----------------------------124853047628807
Content-Disposition: form-data; name="name"
test
-----------------------------124853047628807
Content-Disposition: form-data; name="surname"
test
-----------------------------124853047628807
Content-Disposition: form-data; name="age"
test
-----------------------------124853047628807--
In order to send this data, what I did is create a MultipartEntityBuilder like below:
StringBody name = new StringBody("test", ContentType.MULTIPART_FORM_DATA);
StringBody surname = new StringBody("test", ContentType.MULTIPART_FORM_DATA);
StringBody age = new StringBody("test", ContentType.MULTIPART_FORM_DATA);
StringBody field = new StringBody("", ContentType.MULTIPART_FORM_DATA);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("name", name);
builder.addPart("surname", surname);
builder.addPart("age", age);
builder.addPart("field",field);
return builder;
On top of that the headers that I'm sending are as follow:
post.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0");
post.addHeader("Accept", "text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8");
I tried to set the multiform header but it doesn't work
post.addHeader("Content-type", "multipart/form-data");
Any advice on what I might be missing? THank you