Forum Discussion

JasonZeller's avatar
JasonZeller
Qrew Trainee
8 months ago

Insert in Restful API with JQuery

I am having trouble uploading a record to QB table via Restful API / JQuery. I can pull records without issue. I can also go to the QB API portal and run the same code their without issue.

Even hardcoding the call with dummy data is not working. An internet search did not pull up anything that appeared to pertain to my situation. Can you take a look and see what I might be missing? (function below / error message attached)


headers = {
'QB-Realm-Hostname': 'somesite.quickbase.com',
'Authorization': 'QB-USER-TOKEN blahblahblah',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://somesite.quickbase.com'
};

body = `{"to":"-TABLENAME-","data":[{"6":{"value":"Test Upload 8"},"10":{"value":"HTEST"}}]}`;

const result = await $.ajax({
url: 'https://api.quickbase.com/v1/records/query',
type: 'POST',
headers: headers,
data: JSON.stringify(body),
success: function (response) {
console.log("Success");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});



------------------------------
Jason Zeller
------------------------------

2 Replies

    • JasonZeller's avatar
      JasonZeller
      Qrew Trainee

      Thank you, Marcelo!  This indeed was part of the issue.

      The second part was that I was wrapping the "body" variable with the backtick (`) character.  I removed the backtick and it worked!



      ------------------------------
      Jason Zeller
      ------------------------------