You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by piHuv <ha...@yahoo.com> on 2010/03/25 19:18:50 UTC

Problem Post page using HTTPClient 4.0

Hi,

I get the 400 Bad Request  when I do a Post to a website that has the
"hostname/script?querystring" path in the form action field.  Below is the
link to the website that I try to do a post, a partial html code and the
Java code for the form post.  Hope you can help me with this problem. 
Thanks in advance.

http://www.research.gov/rgov/anonymous.portal?_nfpb=true&_pageLabel=page_research_funding_search&_nfls=false

<form name="Netui_Form_0" id="Netui_Form_0"
action="http://www.research.gov:80/rgov/anonymous.portal?_nfpb=true&amp;_windowLabel=awardInfo_1_4&amp;awardInfo_1_4_actionOverride=%2Fgov%2Fresearch%2Fservices%2FawardInfo%2FbasicSearchCommand&amp;_pageLabel=page_research_funding_search"
method="post">


        url =
"http://www.research.gov/rgov/anonymous.portal?_nfpb=true&_windowLabel=awardInfo_1_4&awardInfo_1_4_actionOverride=%2Fgov%2Fresearch%2Fservices%2FawardInfo%2FbasicSearchCommand&_pageLabel=page_research_funding_search";
        data =
"awardInfo_1_4wlw-checkbox_key%3A%7BactionForm.recoveryAct%7DOldValue=false&awardInfo_1_4%7BactionForm.awardDateEndStr%7D=03%2F04%2F2009&awardInfo_1_4%7BactionForm.awardDateStartStr%7D=03%2F02%2F2009&awardInfo_1_4%7BactionForm.awardeeProjectSearch%7D=&awardInfo_1_4%7BactionForm.maxAwardAmountStr%7D=&awardInfo_1_4%7BactionForm.minAwardAmountStr%7D=&awardInfo_1_4%7BactionForm.personnelSearch%7D=";
        ret = null;
        response = null;
        StringEntity tmp = null;

        httpPost = new HttpPost(url);

        httpPost.setHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux " +
"i686; en-US; rv:1.8.1.6) Gecko/20061201 Firefox/2.0.0.6 (Ubuntu-feisty)");
        httpPost.setHeader("Accept", "text/html,application/xml," +
"application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
        httpPost.setHeader("Content-Type",
"application/x-www-form-urlencoded");

        List<NameValuePair> nameValues = createNameValues(data);
        tmp = new UrlEncodedFormEntity(nameValues, "UTF-8");
        tmp.setChunked(true);
        httpPost.setEntity(tmp);
        response = httpClient.execute(httpPost);
        ret = response.getStatusLine().toString();






-- 
View this message in context: http://old.nabble.com/Problem-Post-page-using-HTTPClient-4.0-tp28032942p28032942.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org