Postman Galaxy Tour Workshop

Logo

Supporting resources for the 2020 Postman Galaxy Tour bit.ly/postman-galaxy-workshop

View the Project on GitHub postmanlabs/galaxy-workshop

Final Countdown

Countdown

< Previous section: Prepare for launch

Now that we’ve tried out collection runs, variables, and test snippets, let’s explore how to pass data between requests and change the order of execution.

1. Import some tests

Open the collection web documentation for future reference.

2. Use variables to pass data between requests

Test scripts let you pass data around in Postman, so you can chain tests together with shared data.

3. Change the request execution

Your scripts can alter the flow of request execution when you use the collection runner.

let jsonData = pm.response.json();
let responseField = jsonData.message;
//check the length of the text
if (responseField.length > 10) {
  //note - setnextrequest only works when you use collection runner
  postman.setNextRequest("Put data");
}
if (responseField.length > 10) {
  postman.setNextRequest(null);
}

4. Share data between collections

You can pass data between requests even if they are not in the same collection. Let’s try that using environments.

{
	"name": "sue",
	"value": "{{bitcoinRate}}"
}

Variable scopes determine where variable values are available within Postman, as well as which one takes precedence if you different vars with the same name.

[winter solstice art](https://apod.nasa.gov/apod/image/1712/WinterSolsticeMW_Seip.jpg)

Recap

In this section we:

Questions?

Shout out any questions you have on scripting request order, passing data around, setting variables from scripts, accessing variables in request body.

Kahoot

Go to kahoot.it and enter the pin shown on the screen—answer the questions as quick as you can to win an Amazon gift card!

Additional resources

Check out the docs:

And more templates you can try out in Postman:

Next steps

Next up: Liftoff