java - Sending JSON from Android to Nodejs server -
i try send request android device nodejs server using
httpurlconnection con = (httpurlconnection) (new url(ip + "/getrestaurant")).openconnection(); con.setrequestmethod("post"); con.setrequestproperty("accept", "application/json"); con.setdoinput(true); con.setdooutput(true); con.connect(); con.getoutputstream().write("{'restaurant_id':'569a16e28dcdc5c8add2a8e0'}".getbytes("utf-8")); con.getoutputstream().flush(); con.getoutputstream().close();
when print received request node js get:
{ "{'restaurant_id':'569a16e28dcdc5c8add2a8e0'}": "" }
instead of {'restaurant_id':'569a16e28dcdc5c8add2a8e0'}
how can work? thanks!
as comment says(i have low reputation comment), {'restaurant_id':'569a16e28dcdc5c8add2a8e0'} not valid context
also advice use koush ion library json requests . https://github.com/koush/ion
it convenient , easy use , give try . in 1 line types of requests done ,
Comments
Post a Comment