# Day 09: Scripting

**URL:** <https://community.postman.com/t/day-09-scripting/24181>\
**Category:** Help Hub\
**Created:** [May 27, 2021, 8:11pm UTC](https://community.postman.com/t/day-09-scripting/24181 "2021-05-27T20:11:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hameethapostman](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hameethapostman](https://community.postman.com/u/hameethapostman)\
**Post date:** [May 27, 2021, 8:11pm UTC](https://community.postman.com/t/day-09-scripting/24181/1 "2021-05-27T20:11:31Z")

</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 am trying to chain request and need some examples to do the same. How do we proceed with this step. I am confused as the first request has a different URL than the second one.  
1st URL is [https://randomuser.me/api/](https://randomuser.me/api/)  
and second is [https://postman-echo.com/post](https://postman-echo.com/post)

1. **Chain the requests** : Return to the **Tests** tab of the first request to capture the data required for the second request. **Use collection variables** this time. Step through the workflow by running each request one at a time to ensure you are getting and setting the variables properly and passing the data correctly.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [May 28, 2021, 12:21am UTC](https://community.postman.com/t/day-09-scripting/24181/2 "2021-05-28T00:21:07Z")

</div>

Hey @hameethapostman,

Please refer [this link](https://learning.postman.com/docs/running-collections/building-workflows/) to learn about chaining.

Chaining the requests is not related to the URL/endpoint. In some cases, we need the input from one request and that goes as input for another request. So here we will be using the “[Variables](https://learning.postman.com/docs/sending-requests/variables/)” to store them (scope of your selection) and use in future when needed. While running it as collection, one request needs to run after another based on the order of the requests placed, which is default running flow.

But if you need to run in a specific flow between the requests, you need to use postman.setNextRequest(“_request name to be run_”), which will help the system to understand what comes next.

---

<div class="post-metadata">

**Author:** ![sseenivasan89](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sseenivasan89/32/8350_2.png) [@sseenivasan89](https://community.postman.com/u/sseenivasan89)\
**Post date:** [May 28, 2021, 12:28am UTC](https://community.postman.com/t/day-09-scripting/24181/3 "2021-05-28T00:28:23Z")

</div>

Hi @hameethapostman,

take all the details (name, email, id) values from the **get random user** and store as collection variable and use postman.setNextRequest(‘echo the user’) to chain the next request as mentioned in step **2. Add another request** , and pass those variables into the **echo the user** as request body

about variables - [refer here](https://learning.postman.com/docs/sending-requests/variables/#variable-scopes)  
about chaining - [refer here](https://learning.postman.com/docs/running-collections/building-workflows/)
