I’m having trouble calling an external API (frame.io) from an Airtable scripting app using remoteFetchAsync().
This is what I’ve tried:
// Change this name to use a different table
let table = base.getTable("
Projects");
// Prompt the user to pick a record
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', table);
if (record) {
// Customize this section to handle the selected record
// You can use record.getCellValue("Field name") to access
// cell values from the record
output.text(`You selected this record: ${record.name}`);
const teamId = 'team_id_hidden_for_security';
const resp = await remoteFetchAsync(
`https://api.staging.frame.io/v2/teams/${teamId}/projects`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer token_hidden_for_security'
},
body: JSON.stringify({
name: record.name,
private: false,
project_preferences: {
collaborator_can_download: true,
collaborator_can_invite: true,
collaborator_can_share: true,
notify_on_new_asset: true,
notify_on_new_collaborator: true,
notify_on_new_comment: true,
notify_on_updated_label: true,
notify_slack: true
}
})
}
);
output.inspect(resp);
} else {
output.text('No record was selected');
}
which results with
{type: "basic", url: "https://api.staging.frame.io/v2/teams/team_id_hidden_for_security/projects", status: 403, statusText: "Forbidden", ok: false…}
type: "basic"
url: "https://api.staging.frame.io/v2/teams/team_id_hidden_for_security/projects"
status: 403
statusText: "Forbidden"
ok: false
headers: Object
redirected: false
I am successful making this call from Postman so I’m wondering if this is CORS related… but I thought using remoteFetchAsync() might resolve that. Could this be related to the “redirect: follow” option mentioned in other posts? What am I doing wrong here?
I’ve hidden my actual team ID and bearer token in my code above for security reasons.
Thank you for your help.