Forum Discussion

JasonZeller's avatar
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': '',
'Authorization': 'QB-USER-TOKEN blahblahblah',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': ''

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

const result = await $.ajax({
url: '',
type: 'POST',
headers: headers,
data: JSON.stringify(body),
success: function (response) {
error: function (xhr, ajaxOptions, thrownError) {

Jason Zeller

2 Replies

    • JasonZeller's avatar
      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