rest - POST Caspio API -


i'm trying post caspio's api - i've been able perform post & requests fine token , retrieve data in xml caspio although having problems using post method data caspio. in example below i've encoded body {"first_name":"john"}.

currently i'm getting 415 unsupported media type - server cannot service request because media type unsupported.

var requestpost = new xmlhttprequest();    function postwebapi() {        requestpost.open("post", "https://c2ezh542.caspio.com/rest/v1/tables/patient/rows", true);        requestpost.setrequestheader("authorization", "bearer " + token_);        requestpost.send("%7b%22first_name%22%3a%22john%22%7d"); 

the table operations specify following:

post table rows

/tables/<name>/rows 
  • method: post
  • description: inserts row table
  • parameters: url, body, required – {“field1″:”value1″,”field2″:”value2”}
  • result: 201 created (if successful) + location header contains url inserted row

use following

var params= {“field1″:”value1″,”field2″:”value2”}; request.setrequestheader("accept", "application/json"); request.setrequestheader("content-type", "application/json;charset=utf-8"); request.send(json.stringify(params));  request.onreadystatechange = function () {`enter code here` if (request.readystate == 4 && request.status== 201) {      var obj = json.parse(response);          } } 

}


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -