The Guide to Perform Manual REST API Testing Using Postman
postman is one of the most popular software testing tools which is used for API testing. Postman is widely used by both software testers and developers for testing as it is easy to integrate with Continuous Integration (CI) & Continuous Development Pipelines. Postman sends an API request to the webserver and receives the response.?So if you are someone who is looking for a complete guide that explains everything from what is REST API to how it works to how it can be manually tested using Postman, you will definitely find this here.
1-API = (Application Programming Interface)
An API is a set of defined rules that enables computers or applications to communicate with one another. APIs sit between an application and the webserver and acts as an intermediary that processes data transfer between systems.
2-What is REST API?
3-Why REST API?
These are the major reasons as to why we choose REST API over the other options.
REST API is
1. Easy to Learn & Implement
2. Easy to Build & Maintain
3. Scalable
4. Cacheable
5. Flexible and Portable
4-How does REST APIs work?
?REST APIs use HTTP requests for their communication. HTTP works as a request-response protocol between a client and server and enables client-to-server communication. For example, your web browser can be considered as the client, and the application on the computer that hosts the website can be termed as the server. So if your browser (client) submits an HTTP request to the server, the server will return a response that contains the status information of the request and the requested content if any were requested.
5-Common HTTP methods (CRUD commands) used in REST API:
CRUD commands = is an acronym that comes from the world of computer programming and refers to the four functions that are considered necessary to implement a persistent storage application: create, read, update and delete.
Most of these commands have very straightforward names that make them self-explanatory. So once you have been introduced to them, it will be very easy for you to remember.
6-API Contract
We have seen the basics of REST API that you will need to know. There are also a?few basics of Postman?that you should be familiar with. But before we can move forward, we have to explore a few aspects of the API contract as you’d have to know the following information to perform manual REST API testing using Postman.
Endpoint = It is the address where the API is hosted on the Server. An End Point Request URL can be constructed as below
Base URL/resource/(Query/Path)Parameters
Resources:
They represent the API/Collection that can be accessed from the Server. We have listed a few common examples below to help you understand better.
Here maps, search and images are the resources of Google.com which is the Base URL.
Path Parameters:
Path parameters are the variable parts of a URL path. They are generally used to point to a specific resource within a collection in the same way how a user is identified by ID.
Example for Path Parameters:
Here 1123343, and 112 are the parameters
Query Parameters:
Query Parameters are primarily used to sort or filter the resources. They can be identified with ”?” (A Question Mark). You’ll be able to identify them once you see a few examples.
Here orders and search are your resources and they are sorted and filtered by the query parameter that is followed by the “?”.
Headers/Cookies:
Headers represent the meta-data associated with the API request and its response. In layman’s terms, it will be used to send additional details to the API for processing our request. An example of it would be the authorization details.
7-Why Postman tool?
Postman is a simple GUI for sending HTTP requests and viewing its responses. It is built upon an extensive set of power tools, which are incredibly easy to use. Postman helps you perform a variety of functions and has a lot of useful functionalities as well.
8-How to create API requests in Postman?
Learning how to create API requests is an integral part of learning how to perform manual REST API Testing using Postman. You will need to know more about the following 2 features to create an API request.
Workspace in Postman:
Postman Workspaces acts as a common working area where you can group your API projects together and use API builder to define APIs or generate API elements. So they are helpful in organizing your API work better and collaborating with your teammates as well. Now let’s see how to create one.
Click on the Workspace dropdown in the header -> New Workspace -> WorkSpaceName (Type any workspace name you wish) -> Create Workspace.
领英推荐
9-Testing POST Request to Log in – Successful:
To make a POST request, click on the More option icon (…) -> Add Request -> Login User
1. From the Dropdown select POST
2. In the “Enter request URL” text box, type the following (URL): https://uplandsoftware.in/api/login
3. Click on Body Tab, select the ‘Raw’ radio button, and then the JSON format from the dropdown list.
4. In the text box, paste the Login Credentials:
5. Click on the Send button
6. You should be able to see the below response:
7. make sure to check for the correct status code
10-Testing GET Request to Get the List of Users:
To make a GET request, you have to click on the More options icon (…) -> Add Request -> Request to Get List of Users (Assign any requested name you wish)
1. From the Dropdown list, select GET
2. Type the mentioned URL (https://reqres.in/api/users) in the “Enter request URL” text box.
3. Click on the Send button.
4. You’ll be able to see the below response:
5. Once again, check for the status code and see if it is ‘Status: 200’.
11-Testing PUT Request to update user Information:
Same as above, you have to click on the More option Icon(…) ->Add Request -> Request to Update user Information (Enter any request name of your choice)
1. Click on ‘PUT’ from the dropdown list.
2. In the “Enter request URL” text box that appears, type this URL: https://reqres.in/api/users/2
3. Click on the ‘Body’ Tab, select the ‘Raw’ radio button, and then choose the JSON format from the dropdown.
4. Paste the Login Credentials in the text box:
5. Click on the ‘Send’ button
6. You will see the response:
7. Check if the status is shown as ‘200 OK’.
12-Testing DELETE Request to Remove Users from Database
Click on the More option Icon (…) -> Add Request -> Request to Get the list of Users (Enter any request name you wish)
1. From the Dropdown list of options, select ‘DELETE’.
2. Type this URL https://reqres.in/api/users in the “Enter request URL” text box.
3. Click on the ‘Send’ button
4. Check is you see the below response:
5. Check if ‘Status: 200 OK’ is visible.
13-How to Download and Install POSTMAN?
Here are the steps to install:
Step 1)?Go to?https://www.postman.com/downloads/ ?and choose your desired platform among Mac, Windows or Linux. Click Download.
Thanks& Amr Rashad