Skip to main content

Command Palette

Search for a command to run...

Testing with Postman: Variables

Updated
2 min read
Testing with Postman: Variables
B
I build automation frameworks — not just tests. Over 10 years I've designed and shipped production testing platforms across payment, insurance, and healthcare domains. My instinct is always toward architecture: clean abstractions, maintainable patterns, and systems that don't fall apart when the product scales. What I'm working on now: - A Claude/Playwright agent framework that generates test cases directly from Jira tickets - Concurrency and race-condition coverage for financial transactions - A modular Playwright/JavaScript platform covering UI and 20+ API service integrations with 100+ JSON schema validators I've built production automation in Playwright, Geb/Spock, Rest-Assured, and Selenium across payment, insurance, and healthcare domains. When a stack isn't working, I replace it. When a pattern is wrong, I fix it. If the automation problem is interesting, I'm probably already thinking about it.

Sorry it has been a while but I recently moved job and house, so life has been hectic. Next we will discuss variables. There are a lot of different variables you can use like Collection, Environmental, path, and others. The main 2 I use are Environmental so that we can have different variables for Dev, QA, Prod and any other environments there maybe.

One thing I will go over later is reusable code. You can store code in an environmental variable.

Setup Environmental Variable

Create an Environmental Variable for the project with the base URL as a variable called url. This allows us to use {{url}} in our calls so we can use the test one both containers.

url - http://www.example.com/api

Using Variable over other API calls

Another trick is using the environmental variable for passing variables from one API call to the next. For example we have an Encryption API.

pm.environment.set("encrypted", pm.response.text()); //Sets the variable and allows us to call it later.

//In the other API we can now use the below as a variable.
{{encrypted}}

Path Variables

One thing you can do when setting up Parameters is store the value in the environmental variable. You can also do this with Path Variables. For example you can call example.com/:variable/. :variable is a path variable and as such you can set it to be an environmental variable or anything else. You are now allowed to change it just like you would a parameter.

Links

Postman Quick Reference Guide Chai Assertion Library Regex Cheat Sheet Postman: The Complete Guide on Udemy

More from this blog

B

Ben Weese - Senior QA Engineer

13 posts

As the son of a programmer I grew up on computers and have always loved them. Now I work as a Software Development Engineer in Test to write code and test things. I also enjoy my homelab hobby.