Help

Re: New 'When webhook received' trigger type - test failures

1142 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Joe_Polidoro
4 - Data Explorer
4 - Data Explorer

Hi,
I’m currently in the process of trying to perform an automated update of a table record based on the trigger type “When Webhook received” (still in alpha dev phase).

It indicates sending a webhook request to an ‘example’ webhook address in order to indicate ID references.

airtable_automation_webhook

I have placed the example webhook address into a script app in the base that is intended to trigger the update automation via webhook. I have also included two input variables in the webhook call.

The intent in doing this is to have the script call the webhook to trigger update automation and use the input variables to a) identify the correct record to update and b) provide the updated value to the intended field to update.

The result is the error in the screenshot below.
This raises the obvious two-part question: Why is the console message indicating that the URL is not found and the automation test failing as a result?

airtable_script_call

Thoughts anyone?
Am I overcomplicating this endeavor to start with?
Thanks in advance!

(Yes, I haven’t been doing Airtable scripting that long)

7 Replies 7

Welcome to the Airtable community!

You need to call the webhook using POST, not the default GET. You also need to include your input variables in the POST body, not as URL parameters.

Hello and thanks for your reply.
Totally makes sense - got stuck on variables and overlooked the method.

I’m having a little trouble finding proper documentation and examples of specifying the POST method and data within a fetch call (inside an AT script app).

I would expect it to be approximately as simple as:

let confirmAll = await fetch({
  method: POST,
  data: {
               classID: config.classID,
               walletCount: config.walletCount
         }
});

Yet, this doesn’t seem to be the case. Still looking for fetch references (currently copying a community example base), but would appreciate any further syntax insights you might have.
Thanks again!
Joe

Are you getting a new different error?

Unless you have a variable named POST with the proper value, you need to put it in quotes.
method: "POST",

Yes, after doing a few variations and bringing it down to the most basic request structure, it’s sending a 400 status (bad request), versus 404 - Not Found. See below

airtable_script_call

Pasted the wrong reply capture - refer to this one instead

image

You need to have your post body in JSON format and have a header that says your content is in JSON format.
You also need to convert the response into readable text.

Here is more documentation about fetch.

akiarostami
4 - Data Explorer
4 - Data Explorer

This is what you should do:

if you’re passing data as JSON, you should call:

const url = "https://hooks.airtable.com/workflows/v1/genericWebhook/urlxyz";
let options = {
    method: "POST",
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({test: false})
}
const res = await fetch(url, options);

And if you want to pass data as parameters:

const url = "https://hooks.airtable.com/workflows/v1/genericWebhook/urlxyz?data=abc";
let options = {
    method: "POST",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
}
const res = await fetch(url, options);