# How to run two prerequisite (POST and GET) request fir a single method. I want POST method to run first but GET method is running first

**URL:** <https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [April 22, 2021, 7:53am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963 "2021-04-22T07:53:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudarshan.ohal](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@sudarshan.ohal](https://community.postman.com/u/sudarshan.ohal)\
**Post date:** [April 22, 2021, 7:53am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963/1 "2021-04-22T07:53:55Z")

</div>

_My question_:

How to run two prerequisite (POST and GET) request fir a single method

_Details (like screenshots)_:  
I have one POST method request suppose C. I need to sun to pre request script A (POST method ) and B (GET method) to provide the required parameters for C request. How can i achived that.

_I’ve already tried_:  
I have tried giving two pre request script but its running GET method first and then POST method. I want POST method to run first.

---

<div class="post-metadata">

**Author:** ![pranavdavar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/pranavdavar/32/9152_2.png) [@pranavdavar](https://community.postman.com/u/pranavdavar)\
**Post date:** [April 22, 2021, 10:04am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963/2 "2021-04-22T10:04:27Z")

</div>

Hi @sudarshan.ohal,

If I understood your question correctly, you want to run 3 different requests and then use response from previous request in next requests.

One way to achieve this is use 3 different requests and have them in collection.

First request will fetch the data and then you can use test to save response in some global or collection variables. That variable can be used in pre test of next request.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![sudarshan.ohal](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@sudarshan.ohal](https://community.postman.com/u/sudarshan.ohal)\
**Post date:** [April 22, 2021, 11:37am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963/3 "2021-04-22T11:37:47Z")

</div>

@pranavdavar : The solution you are telling me, that i have already implemented. However i dont want to include those two request as a main requests in my collection. I want those to be a pre request scripts. Do you know prioritization in pre request scripts?

---

<div class="post-metadata">

**Author:** ![pranavdavar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/pranavdavar/32/9152_2.png) [@pranavdavar](https://community.postman.com/u/pranavdavar)\
**Post date:** [April 22, 2021, 11:55am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963/4 "2021-04-22T11:55:32Z")

</div>

Hi @sudarshan.ohal ,

I believe you are using pm.sendRequest() function of postman.

This is asynchronous function.

> **[Postman JavaScript reference](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#sending-requests-from-scripts)**

If you want to wait for the response to arrive then execute the second request, then you may need to use callback function.

---

<div class="post-metadata">

**Author:** ![toufiqalam](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@toufiqalam](https://community.postman.com/u/toufiqalam)\
**Post date:** [July 27, 2021, 11:37am UTC](https://community.postman.com/t/how-to-run-two-prerequisite-post-and-get-request-fir-a-single-method-i-want-post-method-to-run-first-but-get-method-is-running-first/22963/5 "2021-07-27T11:37:15Z")

</div>

Similar type situation I am facing also. I too have 3 requests . I want to run request A & B (A is GET, B is POST) on the pre request tab of request C. So that I can have necessary info to run request C. Problem I am facing is , when I run request C, B is running first and then A is running . That means POST is running first and then the GET. As a result I am unable to execute the request C.  
This is my pre request script,

> const getOTP = {
> 
> method: ‘GET’,
> 
> url: `${pm.environment.get('base_url')}/${pm.environment.get('common_path')}/otp-login?msisdn=${pm.environment.get('msisdnWhite')}`,
> 
> header: {
> 
> ```
> 'User-Agent': 'something',
> 
> 'Accept-Language' : 'en'
> 
> ```
> 
> },
> 
> };
> 
> const postOTP={
> 
> ```
> method : 'POST',
> 
> url : `${pm.environment.get('base_url')}/${pm.environment.get('common_path')}/otp-login`,
> 
> header: {
> 
> 'Content-Type':'application/json',
> 
> 'Accept-Language':'en'
> 
> },
> 
> body:{
> 
> mode : 'application/json',
> 
> raw: JSON.stringify(
> 
> {
> 
> "msisdn":"12345666666",
> 
> "otp":"0000"
> 
> } )
> 
> }
> 
> ```
> 
> };
> 
> pm.sendRequest(getOTP, (err, response) =\> {
> 
> const jsonResponse = response.json();
> 
> pm.environment.set(“GETOTP”,jsonResponse.result)
> 
> console.log(jsonResponse);
> 
> });
> 
> pm.sendRequest(postOTP, (err, response) =\> {
> 
> const jsonData = response.json();
> 
> ```
> pm.environment.set("access_token",jsonData.access_token)
> 
> ```
> 
> });

Any help is much appreciated. Thanks in advance.
