Hi, I would like to know how to set headers in an Http Post request. This is what I tried: ... HttpPost postMethod=new HttpPost(posturl); postMethod.addHeader("Content-Type", "something"); postMethod.addHeader("Content-Length", "length of content"); String requestBody = "some text"; postMethod.setEntity(new StringEntity(requestBody)); ...
The server that I'm posting to is rejecting this request because it's not able to retrieve the content length. Could anyone help me with this? Thanks. On Nov 23, 7:09 pm, fala70 <fal...@gmail.com> wrote: > Yeah.... Thanks Adam now work > > On 23 Nov, 10:36, "Adam Connors" <adamconn...@gmail.com> wrote: > > > > > Best guess... Do you have the INTERNET permission correctly declared > > in your manifest...? > > > On 11/22/08, fala70 <fal...@gmail.com> wrote: > > > > thanks Adam, for your answer. I tried your instructions but when I > > > call the execute I receive an IOException. Follow the stack log. Any > > > idea ??? > > > > Also I tried to use the same Header, but without success. > > > httppost.addHeader("Content-Type", "application/octet- > > > stream"); > > > httppost.addHeader("Accept", "application/octet-stream"); > > > > stack log. > > > > 11-22 23:05:43.834: WARN/System.err(478): java.net.SocketException: > > > unknown error > > > 11-22 23:05:43.843: WARN/System.err(478): at > > > org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl > > > (Native Method) > > > 11-22 23:05:43.853: WARN/System.err(478): at > > > org.apache.harmony.luni.platform.OSNetworkSystem.createSocket > > > (OSNetworkSystem.java:79) > > > 11-22 23:05:43.853: WARN/System.err(478): at > > > org.apache.harmony.luni.net.PlainSocketImpl2.create > > > (PlainSocketImpl2.java:59) > > > 11-22 23:05:43.863: WARN/System.err(478): at > > > java.net.Socket.checkClosedAndCreate(Socket.java:763) > > > 11-22 23:05:43.873: WARN/System.err(478): at > > > java.net.Socket.connect(Socket.java:910) > > > 11-22 23:05:43.873: WARN/System.err(478): at > > > org.apache.http.conn.scheme.PlainSocketFactory.connectSocket > > > (PlainSocketFactory.java:117) > > > 11-22 23:05:43.882: WARN/System.err(478): at > > > org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection > > > (DefaultClientConnectionOperator.java:129) > > > 11-22 23:05:43.892: WARN/System.err(478): at > > > org.apache.http.impl.conn.AbstractPoolEntry.open > > > (AbstractPoolEntry.java:164) > > > 11-22 23:05:43.892: WARN/System.err(478): at > > > org.apache.http.impl.conn.AbstractPooledConnAdapter.open > > > (AbstractPooledConnAdapter.java:119) > > > 11-22 23:05:43.904: WARN/System.err(478): at > > > org.apache.http.impl.client.DefaultRequestDirector.execute > > > (DefaultRequestDirector.java:348) > > > 11-22 23:05:43.914: WARN/System.err(478): at > > > org.apache.http.impl.client.AbstractHttpClient.execute > > > (AbstractHttpClient.java:555) > > > 11-22 23:05:43.914: WARN/System.err(478): at > > > org.apache.http.impl.client.AbstractHttpClient.execute > > > (AbstractHttpClient.java:487) > > > 11-22 23:05:43.923: WARN/System.err(478): at > > > org.apache.http.impl.client.AbstractHttpClient.execute > > > (AbstractHttpClient.java:465)- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---