Loop step on JSON from HTTP REST API

Hey Adam!

This is a great question - to wire up your REST → loop steps, you can edit the output of the REST step to more granularly define the fields returned in your API call’s response body. Once an array is explicitly defined, the Loop step form should then allow you to select that array to iterate over.

To do this, open your REST step and go to the Configure Details panel, and you should see an Edit option available next to the Output section at the bottom. You’ll see a few fields already defined here - most of these should be left as is - but the body_object output field is the one that contains the full API request body including your user data. Within that body_object field, you can do + Add Variable to define specific fields within that object based on the data from your API. For your case, it looks like you’ll want a variable named object, with Data Type = Array, and Array Type = Object (you could even define subfields in this object with email, first_name etc. but that is not required).

Once that’s done, you should be able to select that body_object.object array variable from the REST step in your loop step.

Just a warning, this output editting should only be done for special steps like REST where there are dynamic outputs - you need to be careful to enter the EXACT field names and data types or else it may not work as expected :slight_smile:

For the Python step, yes, you can pass in any input object and can reference any fields in that object by doing params.get("field name") - e.g. in this case, you could pass in the body_object from your REST step as Input, and should be able to do params.get("object") to access the array. You may have seen this already but there’s some more info on using Python steps here: Python 2 or 3 Script | InsightConnect Documentation

I’ve attached a screenshot of a REST step I have with the customized output schema for a similar use case - hope this helps!

custom output

4 Likes