How to make POST call using HttpURLConnection with JSON data in Android -


please me out problem. want make post call json data should appear in body request not able that. made post call , getting data data not in json format.

code :

data = "{'mobile':'"+mobile_number+"','password':'"+mypassword+"'}"; byte[] datapost = data.getbytes(); urlconnection = (httpurlconnection) url.openconnection(); urlconnection.setdooutput(true); urlconnection.setchunkedstreamingmode(0); urlconnection.setinstancefollowredirects(false); urlconnection.setrequestproperty("accept", "application/json"); //urlconnection.setrequestproperty("content-type", "application/json"); urlconnection.setrequestproperty("charset", "utf8"); urlconnection.setusecaches(false); outputstream os = urlconnection.getoutputstream(); os.write(datapost); os.close(); 

result coming below

body:     {'a':'b','c':'d'}:"" 

please me. new android development.

thanks


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -