ChrisDyroff
4 years agoQrew Member
New RESTful API in Code Pages?
Hi, QB Folks!
Anyone know if you can use the new API inside your Code Pages? I'm getting a CORS error when I try.
I need to combine a few existing QB reports into a single table for reporting, and thought the new API's "reports" endpoint would work well. I'm hoping to use JS to fetch the data and generate a table.
But when I try to pull the data into the page directly, using the JQuery code samples from the API Portal, I get a CORS error.
------------------------------
Chris Dyroff
------------------------------
Anyone know if you can use the new API inside your Code Pages? I'm getting a CORS error when I try.
I need to combine a few existing QB reports into a single table for reporting, and thought the new API's "reports" endpoint would work well. I'm hoping to use JS to fetch the data and generate a table.
But when I try to pull the data into the page directly, using the JQuery code samples from the API Portal, I get a CORS error.
<head>
<script>
var headers = {
'QB-Realm-Hostname': 'xxxxx',
'User-Agent': 'API-Explorer',
'Authorization': 'QB-USER-TOKEN xxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
};
$.ajax({
url: 'https://api.quickbase.com/v1/reports/10/run?tableId=xxxxxxxxx&skip={skip}&top=10',
method: 'POST',
headers: headers,
success: function(result) {
console.log(JSON.stringify(result));
}
})
</script>
</head>
<body>
<h2>Table will go here.</h2>
<table></table>
</body>
When the page loads, in the console:
Access to XMLHttpRequest at 'https://api.quickbase.com/v1/reports/10/run?tableId=xxxxxxxxx&skip={skip}&top=10' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I'm hoping there is a workaround that I'm just missing. Any help is appreciated.
Thanks,
CD
------------------------------
Chris Dyroff
------------------------------