Well, for a starter your #addHeader("Content-Type", "application/
json") doesn't really make sense since you're in fact sending
application/x-www-form-urlencoded when you're pushing an
UrlEncodedFormEntity to the server - otherwise it looks about right.Are you getting a HTTP 3xx redirect - that could .. result in a GET.. I guess? You can disable processing of redirects with HttpClientParams.setRedirecting(.., false) and see if it breaks in new and interesting ways then. On 22 Sep, 16:44, Joshua Partogi <[email protected]> wrote: > Hi there, > > I am trying to send data using POST method from my android apps. However in > the server it is always recognized as GET. I am using Rails apps as the web > service. Here is the snippet of my Android code: > > URI uri = new URI(hostName); > > HttpPost httpRequest = new HttpPost(uri); > > httpRequest.addHeader("Accept", "application/json"); > > httpRequest.addHeader("Content-Type", "application/json"); > > List<NameValuePair> pairs = new ArrayList<NameValuePair>(); > > pairs.add(new BasicNameValuePair("key1", "value1")); > > httpRequest.setEntity(new UrlEncodedFormEntity(pairs)); > > HttpClient httpClient = new DefaultHttpClient(); > > HttpResponse httpResponse = httpClient.execute(httpRequest); > > Have I done anything wrong? Thanks for your help. > > Kind regards, > Joshua. > > -- > @jpartogi -- 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

