android - httpurlconnection post empty json -


i trying post json string linux server. however, says no json object decoded. when testing @ local host 10.0.2.2:5000. can json object.

is there can make work? thank you.

the error shown below: valueerror: no json object decoded

update: think has android permission. in manifest file, i've added

<uses-permission android:name="android.permission.internet" /> 

is there other lines should've added make post request work?

to answer own question:

well, i've resolved problem. turns out have add 1 line: this works.

here code:

                    conn = (httpurlconnection) url.openconnection();                     conn.setdoinput(true);                     conn.setdooutput(true);                     conn.setrequestproperty("content-type", "application/json;charset=utf-8");                     conn.setrequestmethod("post");                     conn.setusecaches(false);                     conn.connect(); 

well, i've resolved problem. turns out have add 1 line:

conn.setrequestproperty("content-type", "application/json;charset=utf-8"); 

this works.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -