Help

Re: How to pass array data in my automation script

196 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Dredd
4 - Data Explorer
4 - Data Explorer

So my goal is to automate image enhancing via form submission.

When my table receives the form submission, most of the time, it will receive multiple images ("rawFiles").

Once it receives the data, it will send a webhook to Make.com where it all goes through the automation.

My issue is "rawFiles" only receives data as a string and not as an array. I would like to pass this data as an array so that my webhook in Make can process it properly.

Here's my current script:

 

let inputConfig = input.config();

let webhook = 'https://hook.us1.make.com/s3i0oapoqp08n8wxigxpv7jl826k24lw';

let queryParams = `/?Record ID=${inputConfig.recordID}
    &Raw Files=${inputConfig.rawFiles}`

const  returnedPayload = await fetch(`${webhook}${queryParams}`);

 

And attached is a screenshot of my test in Airtable.
I'm not good at coding/scripting, so any help or direction will really be appreciated.
2 Replies 2
ScottWorld
18 - Pluto
18 - Pluto

I don’t know how to do this in the Airtable script, so the easiest way for me to do this is to simply send your Record ID to your custom webhook in Make, and then use Make’s Get a Record module to pull in all the fields that you want to use, including any attachment fields.

I discuss this technique more in this thread on how to instantly trigger a Make automation from Airtable.

I also show how to work with Airtable arrays in Make on this Airtable podcast episode.

Hope this helps! If you’d like to hire an expert Airtable consultant to help you with anything Airtable-related, please feel free to contact me through my website: Airtable consultant — ScottWorld 

TheTimeSavingCo
18 - Pluto
18 - Pluto

Try this:

 

 

 

let { recordId, rawFiles } = input.config();
console.log(rawFiles);

let body = {
    "Record ID": recordId,
    "Raw Files": rawFiles
};

let url = 'YOUR_MAKE_WEBHOOK';

// use fetch to send the data via POST with proper headers
fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));

 

 

Screenshot 2024-11-11 at 10.00.18 AM.png