Hi all I'm using HttpClient to create a post request. I send this req to a website but the reply isn't as expected. My request needs to be formatted like this simple request:
This is the req generated by Internet Explorer and I need to replicate it programmatically with HttpClient. I'm using something like
but the response from the server is not ok. The page returned from the server is an error page, it seems that maybe something is missing in the Post headers. Printing the requestEntity request gives me the post request body and this is ok! So maybe it's only a header problem. I know that the 2 important headers are Content-Type and Content-Length, I have check them and they are ok. The Content-Length is correctly set directly by the httpPostMethod.setRequestBody(parameters); and it returns the correct int body size value. So I'm trying to set something like
but the reply is always the error page. Someone knows how to configure a correct Post request with HttpClient based on these param? Thanks [ July 05, 2008: Message edited by: al nik ]
May be what I'm saying is obvious, but did you print the request generated by the HttpClient and compare that with what generated by IE?
Also if you have control over server, can you get some info of what it expects but missing from your request?
Joined: Oct 18, 2007
Hi Santhosh Kumar, thanks for your reply I don't have the control over the server. It seems that the prob is given by a redirect call that sets some cookies. After my request the server returns a redirect to another page an in the http response headers there is a cookie that sets the ASP_sessionID and then redirect to another page. I think that the client.executeMethod(httpPostMethod); method call the redirect automatically without send the cookies back to the server.