Skip to main content
Question

Uncaught TypeError: JSON.Stringify is not a function

  • September 3, 2020
  • 0 replies
  • 177 views

Hello,
I'm trying to utilize the new REST API and am getting an error when I call the below script, which I've put in a code page. Am I missing something simple here?
---
var headers = {
'QB-Realm-Hostname': '{OUR REALM}',
'Authorization': 'QB-USER-TOKEN {MY USER TOKEN}',
'Content-Type': 'application/json'
}
var body = {
"from": "{MY TABLE}",
"select": [
20,
22,
23,
24,
25,
29,
31,
33
],
"where": "{'6'.Ex.'Yes'}AND{'20'.Ex.'New York'}"
}

fetch('https://api.quickbase.com/v1/records/query',
{
method: 'POST',
headers: headers,
data: JSON.Stringify(body)
})
.then(res => {
if (res.ok) {
return res.json().then(res => console.log(res));
}
return Promise.reject({ status: res.status, statusText: res.statusText });
})
.catch(err => console.log(err))
---

------------------------------
Christopher Wheatley
------------------------------
This topic has been closed for replies.

  • Registered
  • September 3, 2020
Christopher,
Two problems - it's JSON.stringify (no caps)
Also you need to add a content-length header (value is the length of the stringified body)
Neil

------------------------------
Neil Schneider
------------------------------