# Loop step on JSON from HTTP REST API

**URL:** <https://discuss.rapid7.com/t/loop-step-on-json-from-http-rest-api/13003>\
**Category:** InsightConnect\
**Created:** [June 16, 2022, 6:55pm UTC](https://discuss.rapid7.com/t/loop-step-on-json-from-http-rest-api/13003 "2022-06-16T18:55:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![charlotte\_mchugh3](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@charlotte\_mchugh3](https://discuss.rapid7.com/u/charlotte_mchugh3)\
**Post date:** [June 16, 2022, 8:56pm UTC](https://discuss.rapid7.com/t/loop-step-on-json-from-http-rest-api/13003/2 "2022-06-16T20:56:28Z")

</div>

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 🙂

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](https://docs.rapid7.com/insightconnect/python-2-or-3-script/#setup-a-python-plugin)

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](https://forum-uploads-hub-prod-1-us-east-1-rapid7-com.s3.dualstack.us-east-1.amazonaws.com/original/2X/c/c96ee06a266c17a7ae5a1ed256da6cc15d3c9378.png)

---

_[View the full topic](https://discuss.rapid7.com/t/loop-step-on-json-from-http-rest-api/13003)._
