Help

Exectute cURL Webhook from Automation

Topic Labels: Scripting extentions
2220 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Brian_Gotti
4 - Data Explorer
4 - Data Explorer

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.