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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -