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 this:
try {
HttpPost httppost = new HttpPost("http://192.168.2.220:8080");
httppost.setHeader("Content-type", "application/json");
ResponseHandler <String> responseHandler = new BasicResponseHandler();
StringEntity se = new StringEntity(object.toString());
se.setContentEncoding(newBasicHeader(HTTP.CONTENT_TYPE,"application/json"));
httppost.setEntity(se);
System.out.println("Request Sent");
String response = httpclient.execute(httppost, responseHandler);
String temp = EntityUtils.toString(response.getEntity());
} catch (ClientProtocolException e) {}
catch (IOException e) {
}
}
I also tried setting:
HttpPost httppost = new HttpPost("http://10.0.2.2:8080");
In all cases, the response is null and the program force closes. am i sending the request correctly? can anyone please guide me here?
Thanks