In my earlier blog posts, I’ve taken a high level look at Postman’s beta feature Flows, and delved a bit deeper into what each of the blocks that make up a Flow actually does.
However, I think when we’re learning, it’s good to have examples we can refer to – that’s always the shortcut I use to get inspired anyway! So here are some working examples I created to help get those creative juices flowing. Note these are all basic Flows that may form part of a larger Flow should you wish to do something more advanced.
All of my Flows use the Restful Booker API, written and maintained by the amazing Mark Winteringham. Click on the links below to access a video and short tutorial on each Flow.
- Flow #1: Passing Variables Between Requests
- Flow #2: Looping Data
- Flow #3: Take Inputs From Multiple APIs
- Flow #4: Passing Data Between Requests
- Flow #5: Generating A Test Summary Report
Flow #1: Passing Variables Between Requests
In this instance, we create a new booking, and pass the created booking ID to a request to GET the information about that ID. This is done via the the “assign values to variables” link within a request without the need to use the now deprecated Assign Variables/Create Variables blocks.
NOTE – pay attention to those yellow warning triangles in the send request – the block will not recognise the response body data unless they have been defined in an example first.
Flow #2: Looping data
*Updated May 2022* If you want to loop through a response and apply a rule to it then you can find an example picture below. Here I take the ID’s from a GET all request, loop through them using a
FOR EACH loop and for each of the ID’s in the request I output to a terminal if the booking id is greater than 100.
Another way to do this is via the Create Data/Loop Over List Flow, also shown in the picture above. Using these blocks, I also execute a further request using the ID from the loop e.g. to GET information on the booking. I then output the test run results to a Test Summary block.
The steps are as follows:-
- Ensure you have an example saved in your collection for the requests you wish to use in the Flow
- Add a
- Add a
Create Datablock, using the data input to select a value (in this case /data/body/ which is a list of booking ID’s)
- add a
Loop Data Untilblock, which tells the Flow you want to do something with the data you’ve created
- Add further blocks to do that thing e.g.
Send Request(adding the variable of bookingid you’ve generated above) or conditional logic
- (optional) to convert the data back to its original state, add an
Terminal/Test SummaryBlocks to output the data so you can ensure it works – it will dynamically update with new information each time the data passes through the loop
Joyce Lin has also done a video here showing another fantastic use of loops.
Inspired by Postman Supernova Sowmya Sridharamurthy’s recent tutorial (which I highly recommend taking a look at) if you wish to loop through data in a List, try using a Select block first:-
Flow #3: Take Inputs From Multiple APIs
This example shows how you can take requests running against two different environments from two different collections and perform a Check on them both to output to a terminal.
Flow #4: Passing Data Between Requests
From version 9.5.0, you can use the Create Durables block to complete the task of passing data between requests – as long as you have created an example API request first! By adding the token as a durable type, the generated value can be persisted throughout the Flow.
Flow #5: Generating a Test Summary Report
My fave Flow! Takes tests run as part of 3 different requests and outputs the results to a single Test Summary Block. Note these can be from entirely different collections if, for example, you want to generate a quick eyeball test report from across all your critical APIs.
I hope these will help you to see how Flows might be useful to you in your testing endevors. You can see a video of a live stream I did with the Postman team where I walk through Flows in more detail here.
Bye for now 👋