Inorder to pass data using http post we need to set content-Type field in http header. Otherwise the server won't recognize your data which have been sent by parms.
Try with the following Example httppost.setHeader("Content-Type","your content type supported by u r server"); On Oct 11, 4:11 am, dashman <erjdri...@gmail.com> wrote: > List<NameValuePair> params = new ArrayList<NameValuePair>(); > > params.add(new BasicNameValuePair("A", "B")); > > even an empty params works fine. > > but as soon as i add en entry - it fails to response code 400. > > the weird thing is i copied this code verbatim from the c2dm > android sample app - of course i could have done something but > i've narrowed it down to one line. > > the problem happens on both the device and emulator. > > On Oct 10, 6:53 pm, Brad Gies <rbg...@gmail.com> wrote: > > > Need to see how you are setting the params to have any idea of how to > > help. > > > My guess is that you are sending an invalid parameter and the server is > > refusing the connection because of that. > > > Sincerely, > > > Brad Gies > > ----------------------------------------------------------------------- > > Bistro Bot - Bistro > > Blurbhttp://bgies.comhttp://bistroblurb.comhttp://ihottonight.comhttp://fo... > > ----------------------------------------------------------------------- > > > Everything in moderation, including abstinence > > > Never doubt that a small group of thoughtful, committed people can > > change the world. Indeed. It is the only thing that ever has - Margaret Mead > > > On 10/10/2010 11:09 AM, dashman wrote: > > > > in the following code - i get an http response code > > > 400 - BAD REQUEST. > > > > if i comment out the post.setEntity() line - then it > > > works fine - response code 200. > > > > of course i've got internet permission > > > > params is a list of 1 entry - string2string mapping. > > > > URI uri = new URI(urlPath); > > > > HttpPost post = new HttpPost(uri); > > > > UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, > > > "UTF-8"); > > > > post.setEntity(entity); // if this line is commented out - > > > the post results in status 200 OK > > > > DefaultHttpClient client = new DefaultHttpClient(); > > > > HttpResponse res = client.execute(post); > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en