Skip to content Skip to sidebar Skip to footer

Sending A Post Request To Localhost

I need to send a http post request from my android device to a web server that is running on my localhost:8080 and is being hosted by the google app engine. the current code is thi

Solution 1:

'Send a request to localhost' means to send it to the local machine. In your case that would be the Android device. You want to send the request to your desktop machine, which is a remote host. The problem is that the Appengine dev_sever by default only binds to the local address, so it can't be accessed remotely (i.e., from your Android device). You need to pass the --address option to make accessible from the outside. Check your computer's IP and pass it as the address. Something like:

dev_appserver.cmd --address=192.168.2.220

Details here: http://code.google.com/appengine/docs/java/tools/devserver.html

Solution 2:

The response of the httpclient.execute method needs to be return on a big HttpResponse variable, so changing "String" to "HttpResponse" will be ok.

HttpResponseresponse= (HttpResponse) httpclient.execute(httppost,responseHandler);

Post a Comment for "Sending A Post Request To Localhost"