As part of our API Testing series, we will see “Sending GET request with params in Postman”.
In last post, we saw how can we send a GET request to list all users. It simply list all users. What if we want to list users based on some conditions? For E.g. List all users whose name is “John”. I am trying to put a filter on result. You can relate this with “WHERE” conditions in SQL.
How to create an URI with params or parameters?
Syntax is as below:
BaseURL + ResourceName + “?” + key1 = value1 + “&” + key 2 = value 2 ……
Key will be params name and value will be param value. Eg. Name is a key and “John” is its value. If we hit the above request in Postman directly we will get users with name as John and gender is female.
How to add params in Postman?
It will be difficult to add params in URI if it is more in number and chances of making mistake is higher. So Postman provides you an easy option to add parameters as key-value pair. Postman will generate required URL with provided params automatically.
Steps to add Params in a request:
- You will see a tab named “Params”. Click on that.
- You will see a table with three columns. Key, Value and Description.
- You need to add params name and its value. E.g. Name and Gender and its values John and Female respectively.
- Description field is optional and it does not play any role in generating URL with Params.
- You can notice as soon as you start adding params, URI in Postman address bar is updating as above.
- You can see check mark prefix to params row. It means you have provided confirmation of use params in GET request. You just click on it. It will be unchecked and you can notice that params is removed from URI.
- Hit the Send button.
- You will see similar result as we did manually above.
Now you can play with Params in Postman. We will see more about it in next post.
More about API Testing in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning