3 things every developer should know how to do in Postman

Recently, I entered into a hackathon hosted by Postman. The challenge was to create an API that was creative, solved a problem, and/or captured the interest of the Postman community. In addition to creating an API, I had to use Postman’s recently unveiled public workspace feature. While I was familiar with Postman prior to this hackathon I only had experience sending requests and viewing their responses. In order to get up to speed, I gave myself a crash course and I’ve decided to share with you the most important things I learned.

Postman Variables

The first thing I learned about Postman was that you could use variables. Variables are convenient for reusing values for requests and scripts within a collection. Previously, I would manually update the request url, query params, and body for each request in my collection. At times this would cause confusion especially when switching between API environments (e.g. dev, qa, & prod). To mitigate this pain point I would create a collection for each environment. Instead of over using collections and cluttering my workspace, I can create a Postman environment and add variables for the base url, query params, and body. This removes the need for extra collections and enables me to switch between environments seamlessly.

Pre-request Scripts

While setting up a POST request, I attempted to set the body with a variable. While I was unsuccessful doing so I learned about Pre-request scripts in the process. Simply put, pre-request scripts are scripts that execute JavaScript prior to sending a request. If you want to create a template for the body of a POST request you will need to leverage a pre-request script. For my simple use case, I just created a script to replace all references to a variable in the body to its actual value. Outside of my use case, pre-request scripts are very valuable when chaining together requests in your collection. Especially if one request depends on the output of another.

API Builder

The last feature I stumbled upon was Postman’s API Builder. The API Builder is a really cool feature, because it enables you to design an API using an OpenAPI Specification. You can generate collections, create mock servers, and create a test suite directly from your schema. Essentially you can design, document, and test your API before writing a single line of code!

Thank You Postman

I am very appreciative for the hackathon, because it challenged me to take a deeper look into Postman. Equipped with the knowledge I’ve obtained over the past few weeks, I am more comfortable navigating Postman and I’m excited to put some of these features to use in future projects.

If you are interested in learning more about my hackathon project you can view my submission on Devpost.

Please don’t hesitate to contact us with any questions you may have.

About the author