I’m trying to use scripting to call APITemplate.io to create a PDF file from some data. The fetch is failing. It works from Postman so I know the call is valid. I’ve taken the exact code from the Airtable script and run it locally in node.js - with the addition of npm install node-fetch
and some top-level async
function syntax so I can await
, and that works fine too. So there’s something about calling the code from within an Airtable script that makes it return with a 303 error. Unfortunately I can’t find any logging at apitemplate.io to help me. Anyone have any ideas as to what I can look at?
let url = "https://api.apitemplate.io/v1/create?template_id=<id>";
let headers = {
"X-API-KEY": "<apikey>",
"Content-Type": "application/json"
};
let body = {content: "data"};
let response = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(body)
});
let result = await response.json();
console.log(`download result from : ${result}`);