Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Exectute cURL Webhook from Automation

Topic Labels: Scripting extentions
291 1
cancel
Showing results for 
Search instead for 
Did you mean: 

If I have a webhook / cURL function (below) - how do I create a script that will run it through timed automation in Airtable?

  curl -X POST https://app.powerimporter.com/v1/api/workflows/XXXXXXXXXXXXXXXXX/XXXXXXXXX/sync
1 Reply 1

Welcome to the community, @Brian_Gotti! :grinning_face_with_big_eyes: Airtable’s scripting environment is based in JavaScript. To make API calls to other services requires use of the fetch command. The rough equivalent of your cURL call above would look something like this:

const options = {
  method: "POST",
  headers: {
    "Content-type": "application/json" // Omit if you're not passing JSON data in the body
  },
  body: JSON.stringify({ key: value }) // Omit if the endpoint doesn't require JSON data
}
const response = await fetch("https://app.powerimporter.com/v1/api/workflows/XXXXXXXXXXXXXXXXX/XXXXXXXXX/sync", options)
if (response.ok) {
  // The call was good. Retrieve returned JSON data like this:
  const data = await response.json()
} else {
  // Something went wrong with the API call. You can check the error like this:
  console.error(`Error ${response.status}: ${response.statusText}`)
}

Beyond that you’ll need to add code to process the returned data, along with setting up an automation to run on a schedule.