Is it possible to iterate over a nested JSON array returned by a REST Data Action using the Loop block in Architect? The Data Action returns a valid JSON object with a contacts array, but the Loop block only processes the first element and ignores the rest. Here is the configuration:
If you check the docs, they mention the loop source must resolve to a flat array, not a nested object property.
You are likely pointing the loop source directly at the root response object. Architect won’t automatically drill into the contacts key unless you explicitly map it.
Try setting the source to dataAction.response.contacts instead of just dataAction.response. This ensures the iterator receives the actual list.
Make sure you validate the exact JSON structure before relying on Architect’s implicit parsing. The suggestion above is correct, but I’ve seen this fail silently when the Data Action returns an object wrapper instead of a raw array.
Verify your REST response format:
Check the raw response in the Data Action debug output.
Ensure dataAction.response.contacts is strictly an array [], not an object {}.
If the API returns { "data": [ ... ] }, map to dataAction.response.data instead.
Here is a quick k6 script snippet I use to validate API shapes before wiring them into Architect flows. It prevents these iteration bugs by failing fast on unexpected schemas.
import http from 'k6/http';
export default function () {
let res = http.get('https://api.mypurecloud.com/api/v2/users');
let body = JSON.parse(res.body);
// Validate array structure
if (!Array.isArray(body.entities)) {
throw new Error('Expected array, got: ' + typeof body.entities);
}
check(res, {
'is status 200': (r) => r.status === 200,
'has entities array': (r) => Array.isArray(JSON.parse(r.body).entities)
});
}
Run this against your endpoint. If it throws, Architect will never iterate correctly.
wrap the array in an object to avoid architect loop parser failures. use {{response.data}} as the source instead of the raw array. see kb-7721 for details.
Ensure your Loop block source explicitly targets the array property within the JSON response object. In my experience with complex data structures in Architect, pointing directly to the root response often results in processing only the first element or failing silently if the parser expects a flat list.
Set the Loop Source to:
This syntax forces Architect to extract the contacts array from the parent object before iteration. If you point to {{dataAction.response}}, the iterator treats the entire JSON object as a single item, which explains why only the first element appears to be processed.
I have encountered similar parsing issues when integrating Genesys Cloud Data Action outputs with downstream logic. The REST endpoint often returns a wrapper object, and Architect’s implicit parsing can be inconsistent with nested arrays. To validate this, add a Log block immediately before the Loop to print {{dataAction.response.contacts}}. The output should be a clean JSON array [{"id": 1, "name": "Alice"}, ...].
If the output is an object {contacts: [...]}, you must use the dot notation shown above. This is consistent with how I handle data extraction in my AWS Glue PySpark jobs, where explicit path selection prevents null pointer errors during transformation.
Also, verify that the contacts field is not null or empty. If the Data Action returns an empty array [], the Loop will skip entirely, which can be mistaken for a parsing error. Add a conditional branch to check {{dataAction.response.contacts.length > 0}} before entering the Loop. This defensive coding pattern ensures your flow handles edge cases gracefully, especially when dealing with pagination or filtered results from the Genesys Cloud API.