Teshan Posted June 26, 2017 Report Share Posted June 26, 2017 Hi, I am trying insert a record which has a auto number. I am trying return auto-number in my response but it returns nothing. can anyone advise on this. table :TBL_TEST{uid autonumber,ID string ,NAME string} function CallWebAPI1() { var params={"ID":"1","NAME":"test"}; request.open("POST", "https://XXXXX.caspio.com/rest/v1/tables/TBL_TEST/rows", true); request.setRequestHeader("Authorization", "Bearer "+ accessToken); request.setRequestHeader("Accept", "application/json"); request .setRequestHeader("Content-Type", "application/json;charset=UTF-8"); request.send(JSON.stringify(params)); request.onreadystatechange = function () { if (request.readyState == 4 && request.status== 201) { var response = request.responseText; //request.responseText returns empty here. } } } Quote Link to comment Share on other sites More sharing options...
0 Vitalikssssss Posted July 4, 2017 Report Share Posted July 4, 2017 Hi Teshan, I am afraid that you will need to use two API calls in your case. First: to run POST request. Second: to run GET request. Quote Link to comment Share on other sites More sharing options...
0 RuisiHansamu Posted October 31, 2023 Report Share Posted October 31, 2023 Hi sharing this forum post that helped me figure out what I'm supposed to do. Quote Link to comment Share on other sites More sharing options...
Question
Teshan
Hi,
I am trying insert a record which has a auto number. I am trying return auto-number in my response but it returns nothing.
can anyone advise on this.
table :TBL_TEST{uid autonumber,ID string ,NAME string}
function CallWebAPI1() {
var params={"ID":"1","NAME":"test"};
request.open("POST", "https://XXXXX.caspio.com/rest/v1/tables/TBL_TEST/rows", true);
request.setRequestHeader("Authorization", "Bearer "+ accessToken);
request.setRequestHeader("Accept", "application/json");
request .setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify(params));
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status== 201) {
var response = request.responseText;
//request.responseText returns empty here.
}
}
}
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.