aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Multipart form-data posting using Apache HttpClient not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Multipart form-data posting using Apache HttpClient not working" Watch "Multipart form-data posting using Apache HttpClient not working" New topic
Author

Multipart form-data posting using Apache HttpClient not working

Claudiu Dobre
Greenhorn

Joined: Jul 30, 2014
Posts: 1
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multipart form-data posting using Apache HttpClient not working