Forums Register Login

Multipart form-data posting using Apache HttpClient not working

+Pie Number of slices to send: Send
I'm trying to post to my website using a java desktop application. I used Apache HttpClient to make the post request and Jsoup to do some parsing after.

This is the form on my website:


(in case someone might notice something is wrong it is is because I deleted css and javascript crap just to keep it short for this forum post. The form on the website fully works)

If I submit the form through my browser the actual data sent is this one:

And it works ok. After I click the Publish button (in the browser) I get redirected from /adauga to /prestari-servicii where I can see that ad I just typed.


Now I tried to mimic the same thing in java using Apache HttpClient



After I run this I get 200 - HTTP/1.1 200 OK Instead of 302 as I get when I use the browser. I also checked the html response and it was the original index.php page instead of the redirect where I was supposed to view my just entered message.

So did I set the cookies right? Or I messed something in the request headers? Like the boundary etc. I had this problem for a week almost. I tried every single httpclient multipart example but they don't seem to work with a "real world" website.

Thank you!
Dinner will be steamed monkey heads with a side of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 11676 times.
Similar Threads
Request parameter is missing
Struts 2 - jquery plugin - autocompleter
How to get Struts select tag's current selected value/id
Dynamic text fields gives java.lang.IndexOutOfBoundsException
Problem with Ajax Double Combo
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:17:34.