Try setting the header Content-Type to

httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");

http://stackoverflow.com/questions/4582471/problem-simulating-http-post-using-httpclient

*Thanks and Regards,
Kumar Bibek*
*
http://techdroid.kbeanie.com
http://www.kbeanie.com*



On Thu, Apr 12, 2012 at 8:44 AM, Farhan Tariq <[email protected]> wrote:

> I get response code 200, response OK. But the html that gets generated has
> the form itself. I think I am making the correct post request, but can't
> figure out why it is not going through. Could it possibly have to do with
> the form page being in ASP ?
>
> On Thu, Apr 12, 2012 at 8:03 AM, Kumar Bibek <[email protected]> wrote:
>
>> What response do you get? Response Code? Also look at the server logs to
>> get a clear picture of what's going on.
>>
>> *Thanks and Regards,
>> Kumar Bibek*
>> *
>> http://techdroid.kbeanie.com
>> http://www.kbeanie.com*
>>
>>
>>
>> On Thu, Apr 12, 2012 at 8:30 AM, Farhan Tariq <[email protected]>wrote:
>>
>>> Hi, I want to submit a form from within my app. The form can be found
>>> here >>  http://customer.chuckwilson.com/Default.aspx
>>> I have added all the parameters, but the request is not going through. I
>>> keep getting the form as the response. What am I doing wrong here? My code
>>> is below:
>>>
>>>  try {
>>>             HttpClient client = new DefaultHttpClient();
>>>             String postURL = "
>>> http://customer.chuckwilson.com/Default.aspx";;
>>>             HttpPost post = new HttpPost(postURL);
>>>             List<NameValuePair> nameValuePairs = new
>>> ArrayList<NameValuePair>();
>>>             nameValuePairs.add(new BasicNameValuePair("txtFirstName",
>>> "android"));
>>>             nameValuePairs.add(new BasicNameValuePair("txtEmailAddress",
>>> "[email protected]"));
>>>     nameValuePairs.add(new BasicNameValuePair("txtStreetAddress",
>>> "streetandroid"));
>>>      nameValuePairs.add(new BasicNameValuePair("txtZipCode", "5454"));
>>>     nameValuePairs.add(new BasicNameValuePair("txtCity", "cityandroid"));
>>>      nameValuePairs.add(new BasicNameValuePair("CallBack",
>>> "rdCallBackYes"));
>>>     nameValuePairs.add(new BasicNameValuePair("txtLastName",
>>> "lastandroid"));
>>>      nameValuePairs.add(new BasicNameValuePair("phone",
>>> "(111)111-1111"));
>>>
>>>                 UrlEncodedFormEntity ent = new
>>> UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8);
>>>                 post.setEntity(ent);
>>>                 HttpResponse responsePOST = client.execute(post);
>>>                 HttpEntity resEntity = responsePOST.getEntity();
>>>                 if (resEntity != null) {
>>>                     Log.i("RESPONSE",EntityUtils.toString(resEntity));
>>>                 }
>>>         } catch (Exception e) {
>>>             e.printStackTrace();
>>>         }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to