Dynamically Map values from an array into a subsequent API call

Hi Make Community,

I’m currently working on an automation scenario where I parse the output from a Lambda function that provides the following JSON:

{
“domain_name”: “example.com”,
“verification_token”: “12345678910111213141516=”,
“dkim_tokens”: [
“ttrf59f4148ggt1465e4f4re89g7418erf”,
“fekfhrj4iu4gbiuh3hbg3buf89b59f4bi”,
“sqtzxpjtffrjiofjriovnornrnf4rfnrgn332”
],
“message”: “Domain example.com successfully added to SES.”
}

My goal: Dynamically map the dkim_tokens (3 values in the array) into a subsequent HTTP API call for updating DNS records in Namecheap. The HTTP call requires me to include all three dkim_tokens separately as follows:

HostName1: dkim_token1._domainkey
Address1: dkim_token1.dkim.amazonses.com
HostName2: dkim_token2._domainkey
Address2: dkim_token2.dkim.amazonses.com
HostName3: dkim_token3._domainkey
Address3: dkim_token3.dkim.amazonses.com

What I’ve Tried:

  1. Parsed the JSON successfully using the Parse JSON module.
  • The dkim_tokens array is available in the output.
  1. Added an Iterator to iterate over the dkim_tokens array.
  2. Attempted to map the output of the Iterator into the HTTP module.

Issue: When mapping the tokens into the API call, I’m only able to map a single value (e.g., dkim_token1) instead of all three. The output seems to lose context when moving between the Iterator and the HTTP call, or I’m missing a key step to dynamically combine the tokens.

What I Need Help With:

  • How do I dynamically map all three dkim_tokens as separate variables (dkim_value1, dkim_value2, dkim_value3) for use in my HTTP API call?
  • Is there a better way to handle and transform this JSON to achieve the desired mapping?

Any insights, advice, or solutions would be greatly appreciated!

Hello @Beinn_Yule,

Your problem

This is the nature of iterator, It takes multiple elements(items) as an array and then processes them one by one. If you know computer programming then it’s the same as loop is used there.

Solution

Instead of the Iterator use the set multiple variable module then use the get() function to fetch the specific item from the array/collection.
After that use those variables in your api call.

To know more about how to use Get check this official Make Academy course.
https://academy.make.com/courses/IntermediateC02


:bulb:P.S.: Always search first, Check Make Academy. If this is helpful, mark it as a solution :white_check_mark: and :+1:
Need expert help or have questions? Contact or comment below! :point_down:

1 Like

Hey Dilip, thanks so much man! I knew it would be something straightforward. Appreciate the help

1 Like