node.js - sending json array from android to node server -
android :
try { jsonobject obj = new jsonobject(); obj.put("id", editid.gettext().tostring()); obj.put("pw", editpassword.gettext().tostring()); final string jsonstring = obj.tostring(); //final string jsonstring = "{\"id=\":\"abce\",\"pw\":\"13447\"}"; log.i("tag",jsonstring); thread background = new thread(new runnable() { @override public void run() { try { log.i("tag", "thread"); url url = new url("http://49.172.86.247:80/login/controller_on"); httpurlconnection hey = (httpurlconnection) url.openconnection(); hey.setrequestmethod("post"); hey.setdoinput(true); hey.setdooutput(true); hey.setrequestproperty("content-type", "application/json"); hey.setconnecttimeout(10000); hey.setusecaches(false); dataoutputstream wr = new dataoutputstream(hey.getoutputstream()); inputstream inputstream = hey.getinputstream(); wr.writebytes(jsonstring.tostring()); wr.flush(); wr.close(); } catch (exception e) { log.e("tag","error"); }
server :
app.post('/login/:termtype', function(req, res){ console.log(req.body); });
i can see {} in node command prompt. sending data html server via form tag work. what's problem?
Comments
Post a Comment