What Is Postman & How to Use Postman to Test API? — Devstringx
What Is Postman?
Postman is a platform or software testing tool used for API Testing. It is a simple GUI (Graphic User Interface) to send and view HTTP requests and responses.
API (Application Programming Interface) is an interface that defines a set of protocols (rules) that help various software components to interact with each other.
What Is Postman Tool Used for?
Postman tool is used to help developers easily create, test, share, and document APIs. Postman is a user-friendly tool that helps us to optimize our time when executing tests.
Features of Postman
- New– It is used to create a unique environment or request
- Import– Used to import collection or environment
- Runner– Used for executing automation tests
- Collections– Created for arranging the test suites
- My workspace– Create new workspace individually or as a team
- History– Used for displaying past requests
- Request Tab– Used for displaying the title of the request
- HTTP request– Used for displaying a dropdown list of various request methods
- Params– Used for writing required parameters for the request
- Authorization– To use/test APIs, authorization is required
- Body– Used to enter data in text/JSON
- Save– Used to save changes made to a request
- Pre-Request Script– Used for executing test scripts before requests
Advantages of Postman
- Using the Postman tool, there is no need to learn a new programming language
- It is easy to understand because of the interactive interface
- Postman tool provides the user to store values in variables at the environment level which can be used in any request URL, header, and body
HTTP means Hyper Text Transfer Protocol which is used to allow communication between servers and clients
Mostly used HTTP methods are:
- GET: This method is only used to retrieve data/information
- POST: This method is used to send data to servers like upload, create, update
- PUT: It sends data to the server to create/update a resource
- DELETE: This method deletes only specified resource
- PATCH: This method is used when there is a need to update only one field of resource
Steps to Use Postman On a Browser
- Go to the Postman website www.postman.com
- Click on the Sign Up for Free button
- Enter the email, username, and password
- Click on Create free account button
- Then, enter your name and what is your role.
- Click on the Continue button
- Now, the Postman dashboard screen is displayed
How to Use Postman for API Testing?
- Open Postman
- Select workspace
Good to Read:- A Detailed Guide on Newman Postman
HTTP Methods for API Testing
However, there are numerous methods of API testing like POST, GET, PUT, DELETE, etc but here we are sharing 02 HTTP methods for API Testing.
1) Testing API Using the POST Method
- Click on the new button from the left side
- Click on Collection and name the collection
- Expand the collection and click on Add a request
- After clicking on Add a request default GET method is selected. Now we have to select the POST method from the dropdown
- Enter request URL with endpoint (login)
- Then click on the body tab, click on raw, and select JSON
- Enter JSON data in the body
- Click on send and see the status and response
- If you enter the request URL without the endpoint then observe status code is different and the response is not correct
Good to Read:- Write & Add Tests Scripts with Postman
2) API Testing Using the GET Method
Add new request and enter URL with API name and parameters
To use parameters, we need to set the environment
- Click on the eye icon
- Click on edit to set the variable to global environment which can be used in all collections
- Use a variable name for URL and Token
- Click on Authorization and select type as Bearer Token
- Enter curly braces then variables are displayed in the dropdown then select the token and save
- After this, click on send button and view the response for getting all projects by the user
Originally published at https://www.devstringx.com on July 13, 2023