Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Multipart form-data posting using Apache HttpClient not working

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic