# How to test a data loop by calling an array variable created in another request

**URL:** <https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557>\
**Category:** Help Hub\
**Tags:** tests, variables, collections\
**Created:** [October 28, 2022, 1:56am UTC](https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557 "2022-10-28T01:56:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohsangmin](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rohsangmin](https://community.postman.com/u/rohsangmin)\
**Post date:** [October 28, 2022, 1:56am UTC](https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557/1 "2022-10-28T01:56:51Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

> Here’s an outline with best practices for making your inquiry.

_My question_: I would like to do a data loop test by creating an array in another request.

_Details (like screenshots)_:

![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/e/3e00b709973f882125381c042a71600c06734b93.png)  
You will get the variable that generated the array when you use it in another request, but when you call it, you can’t always bring the generated array and turn the loop.

Is there a way to run a data loop test on an array generated in another request?

_How I found the problem_:

_I’ve already tried_:

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 28, 2022, 2:24pm UTC](https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557/2 "2022-10-28T14:24:02Z")

</div>

You can save your array to a collection variable, and then use it in another request.

What exactly is it you want to use the array\loop for? What is the next request doing?

Do you want to loop though the array and make separate post\get requests?  
Or do you want to loop through the array as a test.

If you want to loop through the data and make separate requests, then you will have to do this by adding those requests to the test tab of this request, using sendRequest.

As always, please provide screenshots of what you have so far, as it helps with the context.

This should include the request\response, and any code in the tests tab. (Anonymised appropriately of course).

---

<div class="post-metadata">

**Author:** ![rohsangmin](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rohsangmin](https://community.postman.com/u/rohsangmin)\
**Post date:** [October 30, 2022, 7:32am UTC](https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557/3 "2022-10-30T07:32:53Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/d/2d2c5086370c0cd29d97015c88fada941ad6fe2e.png)

The values ​​you create in the array are what should go into the parameter values ​​shown in the picture.

I got an array variable and brought it in, but I tried a loop test, but I don’t know what format it should be because only the first value is in the parameter value.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/1/21f9aae6297e347f1c6d3e3e4a3e9792c3e0b7d2.png)

Therefore, currently I was trying to put fixed values ​​in the array and proceed with the loop test. Is there a way to sequentially put the array values ​​into the parameters after saving them?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 31, 2022, 9:47am UTC](https://community.postman.com/t/how-to-test-a-data-loop-by-calling-an-array-variable-created-in-another-request/40557/4 "2022-10-31T09:47:13Z")

</div>

I’m still not sure what you are trying to do.

Will that form element take an array?

The pre-request script will run once, and the underlying request will also only run once.

In your example, your request will only run once with the last entry in those arrays. It won’t loop though them if that is what you are thinking. It will run with the final entry that is stored in the variable(s).

If you want this to loop through the elements, you have a couple of options.

First option is to create a CSV file and use the Postman runner with the data file as the input.

This will run the request once for each line in the CSV file.

If you are running another request first to populate the array, then you have the option of creating a loop in the tests tab of that request using sendRequest.
