Forum Discussion
NeilSchneider
5 years agoQrew Cadet
Chris,
Did you add the Content-Length header? You'll get an error 400 if that header isn't present.
Also I'm assuming you are replacing the curly bracket enclosed items with the actual values, for example:
'QB-Realm-Hostname': yoursite.quickbase.com
'Authorization': 'QB-USER-TOKEN xxxxxx_xxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx', -where xxx... is a token for your app
"from": "XXXXXXXXX", - where XXX... is the internal table name
Neil
Neil
------------------------------
Neil Schneider
------------------------------
Did you add the Content-Length header? You'll get an error 400 if that header isn't present.
Also I'm assuming you are replacing the curly bracket enclosed items with the actual values, for example:
'QB-Realm-Hostname': yoursite.quickbase.com
'Authorization': 'QB-USER-TOKEN xxxxxx_xxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx', -where xxx... is a token for your app
"from": "XXXXXXXXX", - where XXX... is the internal table name
Neil
Neil
------------------------------
Neil Schneider
------------------------------
ChristopherWhe2
5 years agoQrew Trainee
Neil,
I did. The top section is now like below. Info in {XXXXXX} does contain the real values in the code page, I've obscured them here for security:
var body = {"from":"{XXXXXXXX}","select":[20,22,23,24,25,29,31,33],"where":"{'6'.Ex.'Yes'}AND{'20'.Ex.'New York'}"};
var headers = {
'QB-Realm-Hostname': '{XXXXXXXX}',
'Authorization': 'QB-USER-TOKEN {XXXXXXXX}',
'Content-Length': body.length,
'Content-Type': 'application/json'
}
------------------------------
Christopher Wheatley
------------------------------
I did. The top section is now like below. Info in {XXXXXX} does contain the real values in the code page, I've obscured them here for security:
var body = {"from":"{XXXXXXXX}","select":[20,22,23,24,25,29,31,33],"where":"{'6'.Ex.'Yes'}AND{'20'.Ex.'New York'}"};
var headers = {
'QB-Realm-Hostname': '{XXXXXXXX}',
'Authorization': 'QB-USER-TOKEN {XXXXXXXX}',
'Content-Length': body.length,
'Content-Type': 'application/json'
}
------------------------------
Christopher Wheatley
------------------------------
- ChristopherWhe25 years agoQrew TraineeHi Neil,
I figured it out after a response from QuickBase support. The 'data' key in the fetch() method should be 'body' not 'data' now it works great! I tried with and without the Content-Length header and both ways are working. Thanks for your help!
------------------------------
Christopher Wheatley
------------------------------- NeilSchneider5 years agoQrew CadetNo problem. If you're doing a lot of testing you might want to take a look at Postman, it lets you set up and test an API without any coding...
------------------------------
Neil Schneider
------------------------------
- NeilSchneider5 years agoQrew CadetChris,
The length needs to be the length of the string created by JSON.stringify. Try this:
var body = {"from":"{XXXXXXXX}","select":[20,22,23,24,25,29,31,33],"where":"{'6'.Ex.'Yes'}AND{'20'.Ex.'New York'}"};
var bodyToSend = JSON.stringify(body);
....
'Content-Length' : bodyToSend.length
...
data: bodyToSend
------------------------------
Neil Schneider
------------------------------