How to Use Postman: The Complete Guide 2021

Postman is designed to check requests from the client to the backend server and receive the response back. Backened reply with positive response if there is no error.

In 4 steps access SharePoint online...

Simple communication between client and server can demonstrated by following dialog

request: Hey, give me total number of visitors for my website

reply: Sure, here is the number of visitors for today on

In most of the cases the above conversation never happens and it become little more complex. See the scenario below:

request: Hey, give me total number of visitors for my website

reply: Who are you? or User not found

The above response from the backend has its own error code that comes as a response.

Most common error codes are 500 which is internal server error and 404 which is not found.

505 error indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

404 error indicated that the server cannot find the data that client requested.

postman client server request - How to Use Postman: The Complete Guide 2021

What is Postman used for

Postman is a powerful set of API testing tools that has become indispensable for many developers. Postman is used by over a million developers around the world and the number is growing.

The main purpose of the postman is to create collections with requests to the API. Any developer or tester, having opened the collection, can easily understand how the service works. 

In addition, Postman allows to design an API and create a Mock server based on it. They no longer need to spend time creating stubs. Server and client implementations can be run at the same time. 

Testers can write tests and do automated testing right from the Postman. Postman is documentation rich tools to automate the testing and saves time that can be utilized in other development process.

What are the components of postman

The main concepts used by Postman are Collection at the top level, and Request at the bottom. All work begins with a collection and boils down to describing the API using requests. Let’s take a closer look at everything in order.

Collections in Postman

collections in postman

The collection is the starting point for the new API. One can think of a collection as a project file. The collection brings together all related queries. 

Usually the similar API is described in one collection, but there are no restrictions on doing it differently. A collection can have its own scripts and variables.

Folder in Postman

folders in postman

Folder combines multiple requests into one group within a collection. A folder, like a collection, can have its own scripts, but not variables.

Example: Folder can be created for first version of the API as V1 inside the group requests according to the meaning of the actions performed – “Order & Checkout”, “User profile”, etc

Request in Postman

request in postman

The request is the main component of the collection. The request is created in the constructor. 

The query builder is the main space you will have to work with. Postman is able to execute requests using all standard HTTP methods and all request parameters are under your control. 

You can easily change or add the headers, cookies, and request body as required. The request has its own scripts. 

Pay attention to the “Pre-request Script” and “Tests” tabs among the request parameters. They allow you to add scripts before and after the request. These two capabilities make Postman a powerful development and testing tool.

Scripts in Postman

“Postman Sandbox” is a JavaScript runtime, available when writing “Pre-request Script” and “Tests” scripts. “Pre-request Script” is used to perform the necessary operations before the request.

For example, you can make a request to another system and use the result of its execution in the main request. “Tests” is used to write tests, check results, and optionally store them in variables.

In addition to scripting at the request level, scripts can be created at the folder level, and collection level. 

They are also called “Pre-request Script” and “Tests”, but the difference is that they executes before and after each request in the folder.

Variables in postman

Postman has several variable spaces and scopes:

  • Global Variables
  • Collection variables
  • Environment variables
  • Local variables
  • Data Layer Variables

Global variables and environment variables can be created by clicking on the gear in the upper right corner of the program. They exist separately from collections. 

Collection-level variables are created directly when editing collection parameters.

Local variables are created from executable scripts. There are also data-level variables, but they are only accessible from the Runner.

Collection runner

Collection runner in Postman is designed to test and execute all queries from a collection or a folder. 

At startup, you can specify the number of iterations, how many times a folder or collection, an environment, and an additional file with variables will be launched. 

It’s worth mentioning that queries are executed sequentially, according to their location in the collection and folders. The order of execution can be changed using the built-in command.

After all requests are completed, a report is generated that will show the number of successful and failed checks from the “Tests” scripts.

Console in Postman

image 15 - How to Use Postman: The Complete Guide 2021

Use the console to debug the scripts, and view additional information on requests. The console works both during the launch of a single request, and during the launch of a batch of requests through the Runner. 

To open console in postman, select console icon from the lower left corner of the main window

Also read:

How to Download and Install Postman

Download the client application from postman official website.

  • Open in your browser
  • Scroll down to the bottom and select “Download the App” from Resources or simply click here to go to download page.
  • Click on “Download the App” button to start the download.
  • Once installed. Launce the program and sign in with your postmaster username/email and password.
  • Select new from top left, it prompts you to create a request, collection, environment etc.
different options available in postman
  • Select Collection from the options, give the name to the collection and select create or press enter. The name of the collection could be anything related to the project.
create new collection in postman

After the collection is created, following options are displayed on windows.

  1. The created collection called “POSTMAN ECHO”Query tab
  2. Method to be used for the request
  3. Url
  4. Submit request button
  5. Request parameters
  6. Response options

How to use Postman

All API documentations are pretty much the same. You see which method, URL, body, parameter header etc. should be used.

how to use postman

On the left side there are API functional blocks, divided by categories (Registration, login, personal account with data, receiving content, etc.).

In the center there is information about which method should be used, the URL for sending the request, the parameters that need to be passed in the request body.

Right side displays the responses that comes from the server.

How to use Get method in Postman

In our example, we will pass the request parameters in the URL. “get?post=1” will be added at the end of the URL

running api in postman - How to Use Postman: The Complete Guide 2021

After the method is selected, the URL and parameters are specified, you can send a request to the server by selecting “Send”. The response from the server appears in the response parameter.

From above screenshot, you can verify that the method worked, and server replied with correct data.

How to use Post method in Postman

post method is similar to get method. After entering the URL, just select the method type to post.

  • select post from request method
  • Enter the URL in the URL area
  • Enter the parameter in “Body”. In this example we chose to pass raw as a parameter.
  • Select send.
how to run post in postman