How to Use Postman to Test APIs
March 24, 2020

What is Postman? How to Use Postman to Test APIs

API Testing

This blog will give a step-by-step guide on how to do Postman API testing in order to simplify the API testing process. 

APIs make it possible for any two separate applications to transfer and share data between them. They also make it easier for an application's users to execute actions without having to use the application’s GUI. From the developers' POV, it's an easy way to execute certain functionalities of their app and test it as well.

Using APIs on a daily basis might become cumbersome, as one might have dozens or even hundreds of APIs that he or she needs to use or test. That makes it difficult to keep up with their exact request’s address(es), header(s), authorization credential(s) etc. And it makes it harder to test the API for functionality, security, and exception handling.

Back to top

What is Postman?

Postman is an API client that makes it easy for developers to create, share, test and document APIs. With this open-source API testing tool, users can create and save simple and complex HTTP/s requests, as well as read their responses. 

To successfully run Postman API tests, you need to get Postman installed by downloading it and installing it here.

🚀 Try BlazeMeter today for 360° API testing >>

Back to top

Why Use Postman API Testing?

There are many benefits to using open-source Postman for API testing, including: 

  1. Accessibility from the cloud. When you are signed into your account, you are able to access your files. You can execute Postman API tests anytime, anywhere.
  2. Collaboration. Postman's import and export capabilities make it easier to share files with other team members, enabling closer collaboration. 
  3. Test Creation. You can add test checkpoints such as verifying successful HTTP response statuses to your Postman API calls. This capability can help teams achieve more comprehensive test coverage.  
  4. Automated API Testing. With features such as Collection Runner, you can automate Postman API tests, saving time and resources. 
  5. Simpler debugging. The Postman console makes it easier to debug API tests by helping teams check the retrieved data. 
  6. Collections. Postman's Collections features enables teams to group together multiple related APIs, which helps with organizing test suites.

Upgrade your API testing and monitoring with BlazeMeter — the testing solution preferred by developers.

Start Testing Now

Back to top

How to Use Postman to Test API 

Postman is very convenient when it comes to executing APIs. Once you’ve entered and saved them, you can simply use them over and over again, without having to remember the exact endpoint, headers, or API keys.

Here is a detailed example explaining how to enter a new API request using BlazeMeter’s ‘test create’ API, but you can do this for the product you are developing:

Launch Postman by clicking on the logo. After it completely loads the main screen, follow these steps to create your collection of requests:

  1. On the “collections” tab click on the “+” button to create a new collection. A new collection will appear and you will be able to edit its name, description, and many other settings.
Collections tab in Postman

2. Then right click on that new collection and select “add request” to create your first request.

Add request

3. Select the recently created request and enter the API endpoint where it says ‘Enter request URL’ and select the method (the action type) on the left of that field. The default method is GET but we will use POST in the example below.

Add request

4. Add authorization tokens/credentials according to the server-side requirements. The different methods/protocols Postman supports are: 

  • No Authentication 
  • Basic Authentication (provide username and password only) 
  • Digest Authentication 
  • OAuth 1.0 
  • OAuth 2.0 
  • Hawk Authentication 
  • AWS Signature 
  • NTLM Authentication [Beta]
Protocols supported by Postman

5. Enter headers in case they are required.

Enter headers

6. Enter a POST body in case it is required. In this example, we are creating a BlazeMeter test that requires a JSON payload with relevant details.

Enter a POST body

7. If you wish to execute this API now, hit the ‘Send’ button, which is located to the right of the API request field. You can also click on the ‘Save’ button beside it to save that API request to your library.
 

Hit Send button to execute API

That's it! Now you know how to enter your API request to Postman and save it to your library.

Back to top

How to Create Postman Collections for Sharing BlazeMeter's API

One of Postman's fantastic features is Collections. Collections allow you to group together several APIs that might be related or perhaps should be executed in a certain sequence.

Postman Collections

For example, in the previous screenshot, you can see a collection that includes 4 APIs that are all required to create and run a BlazeMeter test. The first two APIs create the test object - the first of the two applies the necessary configuration, and the following API uploads the script file needed to run it. The last two APIs start and stop the test we created previously. Obviously, they should be executed in that sequence, hence the collection will be sorted accordingly.

Back to top

Running a Postman Collection Using Collection Runner

In order to run a Postman Collection, you will need to use a feature called ‘Collection Runner’ following this steps:

1. In the Postman GUI, in the bottom right corner of the screen, click the ‘Runner’ button.

Click the Runner button

2. Drag and drop the desired collection or folder to the runner window. In our case, it will be the collection called BlazeMeter API.

Move desired collection to the runner window

3. There are additional configuration parameters that you may define. However, this is not mandatory. For example, you can specify the number of iterations you wish to run the collection for, as well as add delays between each API request. There is also an option to choose your ‘Environment’. Environments allow you to customize requests using variables that might include environment-specific values. This is extremely helpful when you are testing against several environments, like the development environment, the production environment, etc. To set up a new environment, click on the eye icon on the top right side of the Postman GUI and select ‘add’. You will be able to add a new one as well as its respective variables.

Set up a new test environment
Back to top

Using APIs Within Your Own App or Script With Postman

Postman also has a feature called ‘Snippets’. You can use it to generate code snippets in a variety of languages and frameworks, such as Java, Python, C, cURL and many others.

This is a huge time saver. A developer can easily integrate APIs with his or her own code without too much hassle. To use it, click on the code tab on the right side of the screen of Postman’s GUI.

Integrate APIs with your own code

Get the most out of your APIs with API testing and monitoring with BlazeMeter. Start testing with the industry leader for FREE today!

START TESTING NOW

 

Related Resources

Back to top