Day 09: Scripting

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines 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/
and second is 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.
1 Like

Hey @hameethapostman,

Please refer this link 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” 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.

1 Like

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
about chaining - refer here

3 Likes