How to do this in Android? (C# Source) -


the objective send data on http post json in it. c# source this:

http.addfilefield("file", "file.text", ms); string json = jsonconvert.serializeobject(d, formatting.none, jsettings); ioutil.writestringtostream(json, ms); ms.position = 0; 

how on android?

try -

    httpurlconnection urlconn = null;     url murl = new url(url);     urlconn = (httpurlconnection) murl.openconnection();     urlconn.setrequestmethod("post");     urlconn.addrequestproperty("content-type", "application/" + "json");     urlconn.setdooutput(true);             //query json string     if (query != null)              {                 urlconn.setrequestproperty("content-length",  integer.tostring(query.length()));                 urlconn.getoutputstream().write(query.getbytes("utf8"));             }     urlconn.connect(); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -