
This article is written to provide the basic knowledge of API testing using Postman . I will also touch a little on Swagger to ensure you have a comprehensive picture how a tester extracts url from Swagger and implements it in Postman. For a start, you can click on the icon below to download Postman for free.
What is API?
API is the acronym for Application Programming Interface. It allows different types of application to communicate with each other by becoming the middleman between any application. For example you can share the song you are listening in Spotify to Twitter with a click of share button. How is that possible? That is because of API.
What is Postman?
Postman is a tool that many testers use to perform API testing . It allows users to perform GET, POST, PUT, DELETE and many other request to web service API.
What is Swagger?
Swagger is an open-source tool that helps developer to document, design, build and consume RESTful web services. In their platform, they have provided a dummy API called Swagger Petstore which I have used in my examples. You will need to visit the website and follow the steps in the upcoming examples in order to follow through this article. You can click on the icon below to visit the dummy Swagger Petstore.
How to find URL In swagger?

- Look for the request name for example GET, click to expand it.
- Box 1 shows Parameters which contains the variables that needs to be send along the request.
- Click the TRY IT OUT button at the place of box 2.
- Select the desired parameter and click EXECUTE.
- You will see a section called REQUEST URL. That is the URL which we will be using to interact with the API in the examples.
EXPLANATION
URL is the API endpoints which we will be using to send request in Postman. Without having these endpoints, we cannot interact with the API. Developers use Swagger to document the list of all endpoints in their application.
Throughout this article, these are the endpoints you will be using :
GET: https://petstore.swagger.io/v2/pet/findByStatus?status=available
POST: https://petstore.swagger.io/v2/pet/petId
PUT: https://petstore.swagger.io/v2/pet
DELETE: https://petstore.swagger.io/v2/pet/01
Now that you are all set with prerequisite of finding url in swagger, let’s get our hands dirty with Postman!
CREATE A COLLECTION

Steps
- At Box 1, click on + NEW COLLECTION.
- Fill in a suitable collection NAME.
- Fill in a brief DESCRIPTION that reflects the purpose of the collection
- Fill up the Authorisation, Pre-request Scripts, Tests, and Variables if applicable.
- Click Create to complete the step.
Explanation
collection is like a project folder that we all create at the beginning of any project to store all files in it.
Authorisation tab allows you to store access token that’s usually required to interact with an API. However in this example, it is not required.
Pre-request Scripts allows you to write and execute any scripts that you may need to pass along with your url.
Test allows you to check the response status after performing an API request. It also allows you to execute any scripts that you might want to do after receiving the response from the server side API.
VariableS tab is the place where you might want to declare any variables especially global variable.
Perform a GET Request

Steps
- At the top panel, click on the + icon.
- At box 1, click on the dropdown and select GET method.
- Copy and paste GET /pet/findByStatus url from Swagger Petstore into the address bar.
- Hit Send button and wait until you receive the response.
- Click Save, and save into the collection we created earlier.
Explanation
Get request is to retrieve all the list of pets that are available in the pet store.
Params, in box 2, is autofilled where its key value pair is set upon copy pasting the url in address bar, which in this example is status = available
. In real testing scenario, you can set and loop through any parameters you want to query by storing the variables in VARIABLES tab as mentioned in creating collection above.
RESPONSE STATUS, in box 3, you will see 3 indicators. Status 200 OK means the GET request sent was a success, Time 6.05s was taken to complete the request and size 54.42 KB which indicates the size of the requested data.
RESPONSE BODY, in box 3, contains the response data . This data is usually formatted in JSON or XML format.
Perform a POST Request

Steps
- At the top panel, click on the + icon.
- Set the HTTP method to POST.
- Copy and paste the POST /store/order url from Swagger Petstore into the address bar section.
- Under the same POST /store/order, copy the entire body section.
- In Postman open the body tab as in Box 2, switch the radio button from none to raw, and paste it into the body section.
- In Box 4, set the dropdown to JSON.
- Hit the Send button.
- Save the file into the collection file.
Explanation
POST request enables us to add a set of data into the server database. Unlike GET request, additionally you will need to send a structured data body with all mandatory tags filled in.
BODY is the tab that allows us to write the data which we want to send. In this example, the attributes tags are id, petId, quantity, shipDate, status and complete. These fields must be filled in with the correct datatype. Any wrong data will result in HTTP 400 error series.
Perform a PUT Request
Steps
- At the top panel, click on the + icon.
- Set the HTTP method to PUT.
- Copy and paste PUT /pet url into the address bar.
- Copy the body section and paste it into the Postman body tab as per Box 5.
- Modify the dog’s name to any name.
- Hit Send button.
Explanation
PUT request is usually invoked to update an existing record in a database. It can also be used to create a record depending on how the API is build. In this example , we have changed the name of a dog in the database.
Perform a DELETE Request
Steps
- At the top panel, click on the + icon.
- Set the HTTP method to DELETE.
- In the previous PUT request example, you would have received an id 1543500600xxxx as part of the return value. This will be your petId. Refer to Box 8 of PUT request example.
- Copy and paste DELETE /pet/{petId} url into the address bar.
- Replace the petId with the id in step 3.
- Hit Send button.
Explanation
Delete request was performed to delete an existing record of a pet in the database. If the delete request was successful, you will receive status 200. Unless the petId is wrong or no longer exist, you will receive status 404.
Summary
What I have demonstrated above are only the basics of RESTful API testing in Postman. It has many more functionalities which are very useful for API testing and can be further extended.
So invest some time to play around with it and you will soon be equipped enough to perform extensive API testing.
I hope you find this article helpful to jumpstart your knowledge in Postman. I will be posting more articles regarding different functionalities of Postman in step by step manner to help you understand more about this tool. Please follow our QA-Synapse blog for upcoming articles. Thank you.
Leave a Reply