Problem
The Loop block just won’t take the array from my POST Data Action. I’m passing {{data.items}} to the input field.
{
"items": [
{"id": "101", "status": "active"},
{"id": "102", "status": "pending"}
]
}
The flow crashes with a INVALID_LOOP_INPUT error every time anyway. Still stuck on the mapping syntax.
The Genesys Cloud Loop block documentation explicitly states it expects an array of objects, not a JSON string. If {{data.items}} is coming back as a stringified JSON blob from your Data Action, the Loop block sees a single string value, not an iterable list. That’s why you’re hitting INVALID_LOOP_INPUT.
Check the actual data type in the Flow logs. If it’s a string, you need to parse it first. Add a “Set Data” block right before the Loop. Set a new variable, say parsedItems, using the expression {{data.items | jsonParse}}. This forces the runtime to evaluate the JSON string into a proper JavaScript array. Then feed {{parsedItems}} into the Loop block.
If data.items is already an object but the Loop still fails, it’s likely a schema mismatch. The Loop input needs to be strictly an array. Sometimes the Data Action returns { "data": { "items": [...] } } instead of just the array. You’d need to map {{data.data.items}} instead.
Also, watch out for null values. If the API returns an empty object {} instead of [], the Loop will error. Add a conditional block before the Loop: {{data.items != null && data.items.length > 0}}. If false, skip the Loop. If true, proceed.
Here’s the quick fix flow:
- Data Action POST
- Set Data:
parsedItems = {{data.items | jsonParse}}
- Conditional:
{{parsedItems != null}}
- True → Loop
{{parsedItems}}
- False → End/Log error
Don’t forget to verify the response format in the API explorer. Genesys endpoints often wrap arrays in a entities or resources key. If you’re hitting a custom endpoint, make sure it’s returning pure JSON arrays, not wrapped objects. The Loop block isn’t smart enough to unwrap those for you.