Architect Loop block failing on JSON array from external API

The Loop block keeps bombing out with a null reference error even though the Data Action is clearly returning an array. I’ve got a Data Action hitting our internal inventory API. The response comes back as a standard JSON array of objects. I’m trying to iterate over that array in Architect to check stock levels, but the loop never enters the body. It just skips straight to the end or throws an error depending on how I map the data.

Here’s the response payload I’m seeing in the logs:

[
 {
 "sku": "12345",
 "count": 10
 },
 {
 "sku": "67890",
 "count": 0
 }
]

I’ve tried a few things:

  • Mapping the Data Action output directly to the Loop input.
  • Wrapping the array in an object first using a Set Data block.
  • Changing the loop type to ‘For Each’.

The documentation says it accepts an array, but it feels like it’s expecting a list type or something else entirely. The error message isn’t super helpful either. It just says “Invalid data type for iteration.” Am I missing a step in the mapping?

What’s the exact data type of the response you’re feeding into the loop? Architect doesn’t automatically parse JSON strings into arrays. If your Data Action is returning a string, the Loop block sees a single item (the string itself), not a collection.

You need to convert that string to an object or array first. Use the JSON.parse function in a Set variable block before the loop.

Set inventoryData = JSON.parse({{dataActionResponse.body}})

Then point your Loop block at inventoryData. If the API returns an empty array [], the loop won’t execute, which is expected behavior. Check the logs to confirm the parse step actually produces an array.