제가 아래 코드와 같이 json을 보내는데요
서버에서 받질 못하네요..
그리고 에러표시도 없고...아무것도 안뜹니다..
그래서 피들로러 직접 값을 보내니 서버에서는 받는걸로봐선 서버문제는 아닌거같은데요
안드로이드에서 json으로 값을 보낼려고합니다..
{
"asd":"asd",
"bbb":"bbb"
}
조언좀 부탁드립니다.
저 아이피는 어짜피 localip라서 상관없습니다..
protected void sendJson() {
Log.i("get", "sendJson Start");
try {
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
HttpResponse response;
JSONObject json = new JSONObject();
HttpPost post = new HttpPost("http://0.0.0.0/viewinsert");
json.put("email", "death");
json.put("password", "dea");
StringEntity se = new StringEntity( json.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = client.execute(post);
/*Checking response */
if(response!=null){
InputStream in = response.getEntity().getContent(); //Get the data in the entity
}
Log.i("get", "sendJson End");
} catch(Exception e) {
e.printStackTrace();
Log.i("get", "Error");
Log.i("get", e.getMessage()+"");
//createDialog("Error", "Cannot Estabilish Connection");
} finally {
Log.i("get", "END");
}
}
서버는 밑에처럼 받습니다.
exports.insert=function(req, res){
req.on('data', function(chunk) {
console.log("Received body data:");
console.log(chunk.toString());
});
req.on('end', function() {
// empty 200 OK response for now
res.writeHead(200, "OK", {'Content-Type': 'text/html'});
res.end();
});
}