Sep 04, 2020 06:31 PM
Hi all
I need to send a json payload to an integromat webhook using an automation triggered by a view but I can’t figure out how to prepare the structure of the array it needs.
I want to loop through a table and then pass these records (containing one field) to integromnat.
I can do it with a single value like this when I map PID to a field
let data = input.config();
const returnPayload = await fetch(`https://hook.integromat.com/3gcj7g0zhntlwgkgm6crtdjo3i1jsvmu?PID=${data.pid}`);
var payloadResponse = await returnPayload.json()
console.log("done");
Has anybody done this before please?
This is what I think I need the array to look like but I still don’t know how to add it to the webhook url
[
{
"name" : "Peter",
"ID" : 1
},
{
"name" : "Mike",
"ID" : 2
}
]
In which case the output will be a series of bundles, each bundle containing one array’s item:
Thanks
Claire
Sep 06, 2020 11:59 AM
Hi @Claire_Conza,
Integromat requires you to use this format when sending a JSON array to Integromat:
[
{
"Array" :
[
{
"PID" : "abc12345"
},
{
"PID" : "def6789"
},
{
"PID" : "ghi10111213"
}
]
}
]
Once you’ve got it structured like that, then go into Integromat’s “Webhook” module, and click on the button that says “Re-determine data structure”, and send some test data to Integromat. Then, Integromat will recognize your new structure as an actual array.
But there’s another step — your next module in the Integromat scenario will need to be the “Iterator” module, which can be found under Integromat’s “Flow Control” options. Set the “Iterator” module to iterate through the Array[]
, not the PID
.
Then, your final module can be Airtable’s “Delete a Record” module (or whatever module you want to use in Airtable). You will need to point it to the PID
from the “Iterator” module, not the PID
from the original “Webhook” module.
So, your final scenario would look like this:
If you click on the Iterator module, it would look like this:
And if you click on the Airtable module, it would look like this:
Hope this helps! :slightly_smiling_face:
Sep 06, 2020 03:51 PM
Thanks Scott
That’s by far the best explanation I’ve had - thanks so much!! Can you help with how would I create that array structure in a loop of my records within an automation script please?
Thanks
Claire
Sep 06, 2020 03:54 PM
Sorry, I don’t know how to do that! But are you sure that you need to send the records from Airtable to Integromat? Can’t you just use a simple “Search Records” module in Integromat to search for the records that you want on a regular time interval?