Introduction to Postman

Kartikey Mishra
9 min readFeb 8, 2022

--

Postman is an application used for API testing. It is an HTTP client that tests HTTP requests, utilizing a graphical user interface, through which we can obtain different types of responses that need to be subsequently validated. It is a great tool for dissecting RESTful APIs made by others or test ones you have made yourself. It offers a sleek user interface to make HTML requests without the hassle of writing a bunch of code just for testing an API’s functionality.

Why use Postman?

With over 4 million users currently, Postman Software has become a tool of choice due to the following reasons:

1. Availability — To use Postman tool, one would just need to log-in to their own accounts, making it easy to pierce lines anytime, anywhere as long as a Postman application is installed on the computer.

2. Use of Collections — Postman lets a user produce collections for his Postman API calls. Each collection can produce subfolders and multiple requests. This helps in organizing test suites.

3. Collaboration — Collections and surroundings can be imported or exported making it easy to share lines. A direct link can also be used to partake collections.

4. Creating Environments — Having multiple environments aids in lower reiteration of tests as one can use the same collection but for a different terrain. This is where parameterization will take place which we will discuss in further assignments.

5. Creation of Tests — Test checkpoints such as validation of a successful HTTP response status can be added to each Postman API calls which helps in insuring test coverage.

6. Automation Testing — Through the use of the Collection Runner or Newman, tests can be run in multiple iterations saving time for repetitious tests.

7. Debugging — Postman press helps to check what data has been recaptured making it easy to debug tests.

8. Continuous Integration — With its capability to support nonstop integration, development practices are maintained.

How to get Postman agent on our device ?

We have options that whether we can download the Postman agent for our devices(Mac, Linux-64bit & Windows-64bit) or we can directly access its’ web version and work on it on our browser.

Whether you access postman by downloading on your device or on web, you need to create an account on postman. For that you can directly sign-up with Gmail id or create a free account.

After that you need to create your user profile.

· Downloading Postman agent

Link to download Postman on desktop devices

Go to the link given above to download the postman agent on your device. It will direct you to the Postman official website downloads section.

From there we can scroll down and we will get this interface so we select our version and download it.

From here you can select your OS version to download.

· Using the Web Version

Link to Postman online platform

As you go on the following link you will be asked to create an account, as explained above .

Getting started with Postman

After successfully creating your account & profile, you will reach to the Home page.

Step 1: Go to “Workspaces” to create your own workspace to work on your projects.

Step 2 : After reaching Workspaces, click on “Create Workspace”

Step 3 : After reaching to the “Create workspace” window, give a name to it & you can define a bit about the workspace. Here we can also choose the Visibility of my workspace .i.e. Personal , which only I can access it or any other visibility according to our need. For example; Private ,which can be accessed only by the invited members of your team . After providing all the necessary data click on “Create Workspace.”

Step 4: After creating your workspace ,create a new collection by selecting “Create Collection”. Enter a collection name, and then select the Create button.

After creating new collection, name it as of your choice.

Making Request

There are 3 key ingredients to make a request which will help in interacting with the API . Which are :

  • Method : GET, POST, PUT etc.
  • Address/endpoint: address of the server (URL). It also involves the protocol that is being used.
  • Path : destination where request can be headed. Ex: search etc.

Response Codes

When testing APIs with Postman, we generally gain different response codes. Some of the most common response code includes:

  • 100 Series: Temporal responses, for illustration,‘102 Processing’.
  • 200 Series: Responses where the client accepts the request and the server processes it successfully, for case,‘200 Ok’.
  • 300 Series: Responses related to URL redirection, for illustration,‘301 Moved Permanently.’
  • 400 Series: Client error responses, for case,‘400 Bad Request’.
  • 500 Series: Server error responses, for illustration,‘500 Internal Server Error.’

Methods

Postman offers many endpoint interaction methods. Following are some of the most used methods, including their functions:

  • GET: Retrieve information
  • POST: Send information
  • PUT/PATCH: Replace & Update information
  • DELETE: Delete information

1. GET Request :

GET method is used to request data from a specified resource that is provided with no changes in the endpoint.

For our tutorial we will be using the following endpoint :
http://postman-student.herokuapp.com/quote

Here we are using the GET request method to get a quote using the API.

In the workspace , we do the following :

  1. Set the HTTPS request to GET.
  2. In the address field we input the URL given above
  3. Click send
  4. We can see status 200 OK i.e. our process is successful.
  5. We can see the output in body in json format.

Adding another request

You can simply press on the new tab to create a new request.

2. POST Request :

POST requests are used to send information to the API server to create a new resource.
Here we are using POST request method to create a new quote and update it to the server by assigning new data to a new index value.

At first, To create a new resource we need to give input. For that we need to give input in body. So we use the JSON format to give it.

In the workspace, after creating a new request we do the following :

  1. Set the HTTPS request to POST.
  2. In the address field we input the URL used previously.
  3. Select the body tab.
  4. Select raw.
  5. Select JSON from the Text menu.

6. We will copy paste one quote result to the given area that we had when we used the GET request , to get the correct format to give input. We need to ensure that the curly brackets are placed properly.

{
“id”: 0,
“author”: “James Baldwin”,
“quote”: “I cant believe what you say, because I see what you do.”,
“source”: “A Report from Occupied Territory”
}

After pasting it correctly we will change the data to create a new quote i.e. id(index), author, quote & source.

7. After that we can see :
i. Send the POST request.
ii. Status code: 201 created, is displayed.
iii. Posted data is showing up in the Body.

To check that a new quote is created in database or not , we can again use the GET request and give the “id : 7" and see the output.
1. Provide the index value 7.
2. Send the request.
3. We can see the output of the response in the body.

3. PUT Request:

A PUT request creates a resource or updates an existing resource. Remember that we need to use the index(id) value of the resource as that particular resource will be updated.
Here we are using PUT request to change the quote of index : 7; that we created, to a new quote.

In the workspace, after creating a new request we do the following :

  1. Set the HTTPS request to PUT.
  2. In the address field we input the URL used previously.
  3. (i) Switch to the body tab, then
    (ii)press to raw, and
    (iii)select JSON under text submenu
    (You can refer to “POST Request” for this step)
  4. We will copy the output of the last request and paste it here.

{
“id”: “7”,
“author”: “Kartikey Mishra”,
“quote”: “Happiness is when what you think, what you say, and what you do are in harmony.”,
“source”: “kartikey.dev”
}

5. Then update the quote to a new quote by keeping the index(id) value same.
6. Click on send(to send the request).
7. We can see the Status code : 204 No Content.

To check that a index 7 quote is updated or not , we can again use the GET request and see the output.
1. Provide the index value 7.
2. Send the request.
3. Status code : 200 OK , request is successfully.
4. We can see the output of the response in the body. The quote of index 7 is updated.

4. DELETE Request

DELETE request deletes an information formerly present in the server. The DELETE method sends a request to the server for deleting the request mentioned in the endpoint. Therefore it’s able of updating data on the server.

Here we are going to use DELETE method request to delete the quote we added to the server.

In the workspace, after creating a new request we do the following :

  1. Set the HTTPS request to DELETE.
  2. In the address field we input the URL used previously & add the index value of the information to deleted i.e. id:7 in our case
  3. Click on Send.
  4. Status code : 200 Ok, request successful.
  5. We can see in the body, that the “Quote with id 7 is deleted.”.

If we go to the GET request and give “id:7" it will show that “Quote not found.”, also the status code : 404 Not Found , says it doesn't found the information of the server.

I hope the “Introduction To Postman” has been delivered successfully. Make sure you implement all of these steps on your device to understand these basic concepts clearly.

--

--

Kartikey Mishra
Kartikey Mishra

No responses yet