java - Uploading JSONObject to Iris CouchDb in Android -


i´m working on app , having problems uploading jsonobject iris couchdb. can´t work.

this code i´m using right now:

private class myhttppost extends asynctask<string, void, boolean> {       @override     protected boolean doinbackground(string... arg0)     {          httpparams params = new basichttpparams();         params.setparameter(coreprotocolpnames.protocol_version,                 httpversion.http_1_1);         httpclient httpclient = new defaulthttpclient(params);         httppost httppost = new httppost("https://dbname.iriscouch.com/dbname");          try {             // add data             jsonobject jsondoc = new jsonobject();             try {                 jsondoc.put("name", "test");                 jsondoc.put("autor", "test author");                 jsondoc.put("rundgangnr", "1");                 jsondoc.put("latitude", 58.0);                 jsondoc.put("longitude", 7.88);              } catch (jsonexception e) {                 e.printstacktrace();             } // end try             string body = jsondoc.tostring();             stringentity entity = new stringentity(body, "utf-8");             httppost.setentity(entity);              // execute http post request             httpresponse response = httpclient.execute(httppost);             httpentity httpentity = response.getentity();             inputstream result = httpentity.getcontent();          } catch (ioexception e) {             // todo auto-generated catch block         }         return true;     }  } 

in oncreate execute function:

new myhttppost().execute(); 

when run app, there no errors nothing gets uploaded. there isn´t change in database.

am using wrong url upload on iris or there wrong code? i´m new android development , appreciate have been struggling days now.

perhaps need use https://accountname.iriscouch.com/dbname rather https://dbname.iriscouch.com/dbname.

also, if request throws ioexception, app silently swallowing error might not seeing it.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -