Automate cURL to run through a list of ID's

1.2k Views Asked by At

I am attempting to run through a list of 10 contact ID's every ten minutes with cURL

This is the code I am trying to run

curl --request POST \
    --url https://youraccountname.api-us1.com/api/3/contactAutomations \
    --header 'Accept: application/json' \
    --header 'Content-Type: application/json' \
    --header 'api-token: test' \
    --data '
{
     "contactAutomation": {
          "contact": THE VARIABLE,
          "automation": 23
     }
}'

The list of contact variables could just be line items in a text file.

Is this something a bash script with cron could handle - and it just deleted the 10 IDs it runs?

Or is this something I would need to use python and a database to run?

This is really a one off thing - so a cron with a script would be easiest since it doesn't need to be used more than one time through.

1

There are 1 best solutions below

0
On

If you have a constant list of IDs:

for id in 123 456 555 777
do
    curl --request POST \
        --url https://youraccountname.api-us1.com/api/3/contactAutomations \
        --header 'Accept: application/json' \
        --header 'Content-Type: application/json' \
        --header 'api-token: test' \
        --data "
    {
         \"contactAutomation\": {
              \"contact\": $id,
              \"automation\": 23
         }
    }"
done