Forum Discussion
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
------------------------------
NeilSchneider
5 years agoQrew Cadet
Chris,
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
------------------------------
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
------------------------------