Trying to iterate over a JSON array returned from a REST Data Action in Architect. The endpoint returns a simple list of IDs.
Response payload:
{
"results": [
{"id": "101", "status": "active"},
{"id": "102", "status": "pending"}
]
}
I mapped the results field to a variable list using a JSON Path. Then I dropped a Loop block, set the input to list, and the iterator variable to item. Inside the loop, I’m trying to assign item.id to a string variable current_id.
The problem is current_id only holds the last value after the loop finishes. It looks like the variable assignment inside the loop isn’t persisting or accumulating. I just need to process each ID sequentially. Am I missing a step in how the iterator variable works with the Data Action response structure? The debug log shows the loop runs twice but the state resets.
Current Item.id
You're likely referencing the root variable instead of the loop iterator. In the Loop block config, make sure you're binding to `Current Item.id` not just `id`. The scope shifts inside the iteration.
Setting the input to Current Item.id definitely fixes the scope issue, but there’s another trap here. The Data Action returns a JSON object, not the array itself. You’re mapping the results array to the variable, which is correct, but if the JSON path isn’t strictly /results, the Loop block receives an object and fails silently or iterates once.
Make sure the Data Action output mapping uses the exact path:
$.results
Then in the Loop block, set the Input to that variable. The iterator will handle each object. Inside the loop, reference properties like Current Item.id and Current Item.status. It’s easy to assume the root object is the array. It’s not. The structure is { results: [...] }. Double check that the variable type in Architect is set to Array, not String or Object. If it’s String, the loop won’t iterate correctly.
Also, verify the REST Data Action has “Parse JSON” enabled. If it returns a raw string, the JSON path evaluation fails. You’ll see an empty array or null in the debug trace. This is a common oversight when moving from simple key-value responses to structured arrays. Check the raw response in the debug window to confirm it’s parsed correctly before it hits the Loop block.