# Send multiple get request and then a single post request

**URL:** <https://community.postman.com/t/send-multiple-get-request-and-then-a-single-post-request/42210>\
**Category:** Help Hub\
**Created:** [December 20, 2022, 6:44am UTC](https://community.postman.com/t/send-multiple-get-request-and-then-a-single-post-request/42210 "2022-12-20T06:44:37Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [December 22, 2022, 2:56pm UTC](https://community.postman.com/t/send-multiple-get-request-and-then-a-single-post-request/42210/5 "2022-12-22T14:56:58Z")

</div>

I had a bit of time today, so I created a simple example.

This is using a POST request to Postman Echo to loop through the responses.  
The final request is a GET request to Postman Echo.

I’ve not done the 5% logic, but I’ve just incremented ltp by 1 each time until I hit 10.  
You’ll have to code that bit yourself.

Using a very simple body with the ltp value coming from a collection variable. (Initially set to 5).

```auto
{
"ltp": {{ltp}},
"Price": 5.6,
"High": 5.6
}

```

This is the Tests tab.

```auto
response = pm.response.json()
var currentltp = response.data.ltp;
console.log(currentltp);

pm.test(`ltp=${currentltp} - Status code is 200`, () => {
    pm.response.to.have.status(200);
});

if (currentltp < 10){

    currentltp++; // increment by 1
    pm.collectionVariables.set("ltp",currentltp);    
    postman.setNextRequest("Request_Name"); // keep looping until ltp is more than 10

} else {
    
    pm.sendRequest({
        url: 'https://postman-echo.com/get?ltp=' + currentltp,
        method: 'GET',
     }, function (err, res) {
        if (err) {
            console.log(err);
        } else {
            pm.test("Final GET Request - Status code is 200", () => {
                pm.expect(res).to.have.status(200);
            });
            
            let resJson = res.json();

            pm.test("Final GET Request - ltp=10", () => {
                // console.log(resJson);    
                pm.expect(parseInt(resJson.args.ltp)).to.eql(10);
            });

            
        }
    });

    currentltp++; 
    pm.collectionVariables.set("ltp",currentltp); // 11
    // the pre-request script will set ltp back to 5 once it hits 11

    postman.setNextRequest(null); // break the loop

}

```

I’ve also added a tiny bit of code to the Pre-request script to set ltp back to 5 once the threshold has been hit. (So I don’t have to go and reset the variable each time I run the test).

```auto
var currentltp = pm.collectionVariables.get("ltp");

if(currentltp === 11){
    pm.collectionVariables.set("ltp",5); // set LTP back to 5.
}

```

---

_[View the full topic](https://community.postman.com/t/send-multiple-get-request-and-then-a-single-post-request/42210)._
