How to test multiple APIs in Postman with one click
Today I will show you how to test multiple APIs in Postman with one click.
I will use JSONPlaceholder — Free Fake REST API (typicode.com) to test the API.
I will show you how to test two API on the following
First API we create to get all posts like this. the response API has 100 post data.
the second API we will get only the first post data.
when you write a test case you click on the test tab. it will show the editor for you to write a test case.
Postman has many snippets you can use to test on the right side of the text editor. for example, you can click ‘Status code: Code is 200’ and the postman will generate code for you
In the first API, I will check the status is 200, and the length of the post array has to be 100. and pass the first Id for the post array to the second API.
I set variables to the collection, so you can see where the variable is stored. when you click on your collection tab the variable are stored here.
you can modify or init variable here.
the second API will use id gets from the first API, then check status 200 and check id is equal to 1 that we want.
when you have written a test case for two API, is time to automate these two API.
on the right bottom tab, click the runner button.
it will show the runner page for you
make sure you have saved all requests. you can click on your collection and drag the collection to the runner order page. click save response if you want to.
now you can click run and see the test result.
you can click for each API to see request info
now you know how to automate test API in your collection.
thank you for reading & enjoy your coding :)