Using Postman Like a Pro!
Chris Achinga
Posted on June 4, 2021
Postman is an API testing platform. You can use postman web platform:
or the desktop application for testing your APIs.
Postman can be used to test all API requests: get/put/create/delete
If you are new to postman, I'd suggest you go through their Bootcamp: https://web.postman.co/bootcamp
I will be using the desktop application for the demos, they're no big differences from using the web version of postman.
What this article covers:
- Creating collections
- Adding requests
- Creating environments and Variables
Creating Collections:
In Postman, collections are folders where you put all APIs with similar descriptions or projects together. It is a pretty neat way to organize your APIs for testing.
https://www.postman.com/collection/
Follow the few steps to create an API collection:
- Ensure that you are on the
collections
tab by clicking on theCollections
with a folder icon on the top left side menu.
On the right of the Collections
notice the "+" icon and on hovering it, a pop up with the message: "Create new Collection" appears.
- Click the "+" icon to create a new collection. Notice a new folder is created
New Collection
and a new tab opened simultaneously.
Right-click on the folder and select rename
to give the collection a name of your choosing or double click on the new collection
name on the tab to rename.
PSST! I will rename mine to Demo
Adding requests to a Collection:
On hovering over the collection name on the left panel. notice the 3-horizontal-dots, click on it to open a quick menu.
Select Add request
and notice a new tab opens:
Let's add an API endpoint and make a request:
https://jsonplaceholder.typicode.com/users
Paste the URL in the input label with a placeholder text "Enter request URL", ensure the method on the left is set to "GET" and hit 'Send' to make a request.
The response:
Creating environments and Variables
An environment in postman is just a collection of variables to be used in a request or a collection
https://learning.postman.com/docs/sending-requests/managing-environments/
The selected environment status is at the top-right of Postman, the default is "No environment".
Here is how we create a new environment and add our variables:
On the left side of the postman web/app, click on the Environment
.
Click on the "+" icon to create a new environment, then give it a name.
To create a variable, manually fill the details on the environment tab:
I will create a variable for the base URL of the API endpoint: https://jsonplaceholder.typicode.com/
VARIABLE: url
INITIAL VALUE: https://jsonplaceholder.typicode.com/
CURRENT VALUE: https://jsonplaceholder.typicode.com/
To use the variable, go to the request tab and replace the https://jsonplaceholder.typicode.com/
with {{url}}
Then on the top-right, select an environment (select the one you just created from the Dropdown).
After that, make the request to see if everything went well:
That is it, to view the demo use:
NOTE
There are many ways to create a variable, environment or collections in Postman, I just highlighted the common ones. Feel free to hover on the postman docs to learn and practice more:
https://learning.postman.com/docs/getting-started/introduction/
Posted on June 4, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.