/ #api 

Use Postman for API Testing or Validation [Tooling]

Postman LogoWelcome to this new blog post series on tools that I use and recommend. For this one, I decided to start with Postman. :)

When I started working with API a few years back, I started with a Firefox plugin, RESTClient. After a laptop change, I had to reinstall Chrome and I tried Postman as a Chrome extension…and I didn’t changed anymore since that moment! :)

So, what is Postman exactly? Postman is a REST client for interacting with HTTP APIs, available as a native app or as a Google Chrome app. It offers a slick user interface and powerful features (see below) to make API requests without the need of writing some code to just test an API functionality.Supercharge your API testing with Postman

Why Postman?

Postman makes it easy to test, develop and document APIs by allowing you to quickly put together simple (or complex) HTTP requests. I see many benefits of using it:

  • easy-to-use interface: clean and intuitive interface (multi-windows and multi-tabs).
  • low learning curve.
  • requests history which contains all the requests that were run in the past in a chronological order.
  • collections (see below).
  • environments to manage your variables (see below).
  • automation capabilities.
  • sharing capabilities: you can share collections with your team or via a link.
  • team library.
  • syncing: makes all your Postman data available wherever you’re signed in to your Postman account. The following entities are synced and saved to the cloud: Collections, Folders, Requests, Responses, Header Presets, Environments, Environment variables, Global variables and Collection run results.
  • dark theme (I like dark themes). :)

Postman is available as a native app for Mac, Windows, and Linux operating systems, but also as a Chrome app. _NB: using the Postman native app is recommended as the Postman Chrome app is being deprecated. _

Postman Launch Screen Help

Postman is available in 3 different editions, which are described on the pricing page. While the standard free version (Postman) will certainly fit your requirements, Postman Pro and Postman Enterprise can make sense for developers, and people working full-time with API.

Environments

Variables are symbols that can take different values. Environments are a set of key-value pairs, with the key as the variable name.

While working with APIs, you will often need to have different setups (e.g., the development server, the production server). Environments give you the ability to customize requests using variables. This way you can easily switch between different setups without changing your requests.

Below, I have a ‘ZONE-51’ environment, with 2 variables defined: {{nsxmanager}} and {{scopeid}}.

Postman Environments to save your variables

In the following API call, I’m using variables which are translated in values by using the ‘ZONE-51’ environment.

Postman Environments: variables matching with the API request

Environments can be downloaded and saved as JSON files to be uploaded later.

Postman Collections

Postman Collection are used to group individual requests together: they help you to consolidate requests, parameters, descriptions, tests, scripts in folders. Collections are great for:

  • Organization - Group together requests into folders and collections (to not have to search through your history over and over again).
  • Documentation - Add a name and descriptions to requests, folders, collections.
  • Test suites - Attach test scripts to requests and build integration test suites.
  • Conditional workflows - Using scripts, you can pass data between API requests and build workflows that mirror your actual use case of APIs.

You can also import collections: I use for example the Postman Collection that is available for the NSX for vSphere RAML file. It’s fantastic to use as the API coverage is complete, calls are documented, XML body is pre-populated in case of POST/PUT requests, and so on. When sharing collections, variables are included in the API calls instead of the API keys, hence the power of the environments which store the variables.

Postman: NSX-v collection

Additional collections resources:

Code Snippets

Once you have validated and finalized your request in Postman, what’s next? You might want to make the same request from an application or from your automation tool. Postman lets you generate snippets of code in various languages and frameworks that will help you do this.

Look for the ‘Code’ link in the top right corner, below the Save button.

Postman Code Snippets

Postman: cURL Code Snippet Example

Use the dropdown menu to select a language (some have multiple options).

Postman: Code Snippets Supported Languages and Frameworks

Copy to the clipboard and use the snippet wherever you want.

Author

Romain

Staff II Technical Product Manager, technologist with 18+ years of Networking and Security experience in Data Center, Public Cloud & Virtualization (VMs and Containers). He is a double VCDX (DCV and NV, #120), VCDX panelist, frequent VMUG/VMworld speaker and contributor to the community via this blog or social media (follow him on Twitter @woueb).