ankush pawar
ankush pawar

Reputation: 61

How can i run another api after i get the response for current api in postman

Good afternoon. Please help me in the below scenario,
I have two api: 1) ABC api 2) XYZ api
ABC api alters the output of XYZ api, I create a collection and add this two api in this collection, and I want the execution sequence like below:

  1. Execute the ABC api and get the response, but before I run a test script related to ABC api I want to run XYZ api.
  2. Execute XYZ api.
  3. Start executing the test script of ABC api which is not executed in sequence 1.

How can I achieve this sequence using postman?

If the question is not clear please let me know, I will try to be more descriptive, Thank you

Upvotes: 0

Views: 1356

Answers (1)

Makus
Makus

Reputation: 109

Under the "Pre-request Script" you can make a call to your abc API. And set it to a variable. enter image description here

Like :

const response = await fetch(httpAdressAsString);

Or use the snippet of Postman:

pm.sendRequest("https://postman-echo.com/get", function (err, response) {
    console.log(response.json());
});

Upvotes: 0

Related Questions