Mini Flow: Build a JSON body with a dynamic list of items for Make HTTP Request
Most APIs accept a body that contains a list of items: records, users, line items, rows, invoices, recipients.
When the number of items is fixed, this is easy — you type them into the Make HTTP Request body by hand:
{
"users": [
{ "name": "Ann", "email": "ann@company.com" },
{ "name": "Bob", "email": "bob@company.com" }
]
}
But when the list is dynamic — a Google Sheet with 5 rows today and 60 tomorrow, all users in a department, every line of an invoice — you can't hardcode it. And sending one HTTP request per item is slow, hits rate limits, and gives you no single response to check.
This mini flow solves that. You loop over your collection, add one item to the body per iteration, and send one request at the end with everything in it.
How to use it
Just follow what the flow does — there are only four pieces.
1. Set Variable, before the For Each
Create a Text variable (in the flow it's called jsonInput) and put your whole body in it: every fixed parameter, every static field, exactly as the API expects. Where your list should go, write a placeholder in double curly braces:
{
"users": {{users}}
}
One rule to remember: name the placeholder exactly like the key it fills. The key is "users", so the placeholder is {{users}}.
2. For Each
Point it at the collection you want to iterate — sheet rows, table records, a list of people, invoice lines, anything.
3. Execute Script, inside the For Each
The script has only three inputs:
Input What to put there body the jsonInput variable placeholder {{users}} newItem the JSON of the single item you want to add — build it with tokens from the current iteration
Example of newItem, using For Each tokens:
{ "name": "<Current Item.Name>", "email": "<Current Item.Email>" }
4. Set Variable, still inside the For Each — as the last action
Set jsonInput = the script's bodyJson output. This is what carries the growing body into the next iteration.
Then, after the loop: in Make HTTP Request, set the Request Body to the jsonInput variable. Nothing else. It is already a complete JSON string, so you don't need a Convert to JSON String action.
A really short example
Collection: two users from a sheet.
Variable before the loop:
{ "users": {{users}} }
newItem on iteration 1:
{ "name": "Ann", "email": "ann@company.com" }
newItem on iteration 2:
{ "name": "Bob", "email": "bob@company.com" }
Variable after the loop — this is what goes into Make HTTP Request:
{ "users": [ { "name": "Ann", "email": "ann@company.com" },
{ "name": "Bob", "email": "bob@company.com" } ] }
That's the whole idea. The placeholder becomes an empty array on the first iteration, and every iteration after that appends one more item to it.
Two lists in the same body?
That works too. Put a placeholder for each one and run a For Each for each list:
{
"invoices": {{invoices}},
"bills": {{bills}}
}
Use {{invoices}} as the placeholder in the first loop and {{bills}} in the second. Both loops read and write the same jsonInput variable, and each item lands in its own array. The order of the loops doesn't matter.
Good to know
The script never touches anything that isn't a placeholder — static fields and static arrays stay exactly as you wrote them.
If something is wrong (invalid JSON, an item that isn't a JSON object, a placeholder that doesn't match any key), the script returns an error output and leaves the body untouched instead of sending a broken payload. Check the matchedBy and error outputs in the run log while you're testing.
Many APIs limit how many items one request may carry (Salesforce composite/tree stops at 200, for example). Check your API's limit before pointing this at a very large collection.
Please download the flow, import it into your Designer, and use it. Replace the sample body with your own, point the For Each at your own collection, and you're done.
Dynamic collection body builder_1788025794587.json