Skip to main content

Hi all,

I try to run this script :

"when a button is clicked in an interface this script is running. It's pointing to another automation triggered by this webhooks to create a new record in a table.

 

 

const URL_AIRTABLE_WEBHOOK = 'https://hooks.airtable.com/workflows/v1/genericWebhook/XXXXXXXXXX/YYYYYYYYYYY/ZZZZZZZZZZZ' let config = input.config() let response = await fetch(URL_AIRTABLE_WEBHOOK, { method: 'POST', body: JSON.stringify({'dossier_record_id':config.dossier_record_id}), headers: { 'Content-Type': 'application/json', }, }); console.log(await response.json());

 

 

But It returns :

ERROR

There was an unexpected error while executing your script.

I'm tired and I don't see my error... After all I want is to create a new record in a table when a button is clicked... is there another to do that ?

Thanks !

I think the script is fine.
Is your input.config set up correctly?

And does it need to be a webhook to create a record with a button?
Do you create the record in an external Airtable? Normally a webhook is created with "Create record".


You're not authenticating the API call. Try this

//schema.bases:write scope required in https://airtable.com/create/tokens let TOKEN = 'YOUR_PERSONAL_ACCESS_TOKEN' try { let response = await fetch(API_URL, { method: 'POST', body: JSON.stringify({ dossier_record_id: config.dossier_record_id }), headers: { 'Content-type': 'application/json', Authorization: `Bearer ${TOKEN}`, }, }); console.log(await response.json()); } catch (err) { console.log(err); }

 Also, if you're trying to activate an Airtable automation from an interface button, Airtable has a built in trigger for this.


You're not authenticating the API call. Try this

//schema.bases:write scope required in https://airtable.com/create/tokens let TOKEN = 'YOUR_PERSONAL_ACCESS_TOKEN' try { let response = await fetch(API_URL, { method: 'POST', body: JSON.stringify({ dossier_record_id: config.dossier_record_id }), headers: { 'Content-type': 'application/json', Authorization: `Bearer ${TOKEN}`, }, }); console.log(await response.json()); } catch (err) { console.log(err); }

 Also, if you're trying to activate an Airtable automation from an interface button, Airtable has a built in trigger for this.


Did I need to process an access token for Webhook?
In my environment, it works fine without an access token.


I think the script is fine.
Is your input.config set up correctly?

And does it need to be a webhook to create a record with a button?
Do you create the record in an external Airtable? Normally a webhook is created with "Create record".


In fact, it was Airtable the problem... the server was down....


Wow, seems like an AWS problem😂