Jonathan Brizio
Posted on November 15, 2019
In these last months, I learn a lot about this great tool that allows me to speed up and optimize my workflow reducing time on repetitive tasks.
If you're new with this tool, I recommend it before to read the entire documentation to look at the features and practice with some real cases.
👉 Setting environment variables automatically
So, let's start with my favorite trick. This is a script to be executed each time that copies the result of the petition and saves it into environment variables. This is great when you need to specify an authentication token that expires at a certain time.
var data = JSON.parse(responseBody);
pm.environment.set("Access-Token", data.access_token);
With that code, you're copying to your environment variable "Access-Token" the value obtained after executing the request. This script avoids copy and pastes values manually in your environment variables. In this way, you only need to invoke that variable to get the value in the authentication input or somewhere.
👉 Replicating an entire request
Another common trick is that it allows reproducing a request. Let's say we want to reproduce the same request when access to Coindesk to obtain the price of the bitcoin.
Open the browser development tools on Chrome. Then, go to the "Network Tab" and filter the requests desired. Right-click the one you are interested in, and select "Copy as cURL". Now we have the cURL, go back to Postman and click on the top-left of the screen the button "Import", and choose "Paste Raw Text" tab. Paste what you copied, and press Import. Now press "Send" and the request would be executed directly from your client.
💬 Sharing your knowledge
And you, what other trick knows with Postman? Post a comment below.
Posted on November 15, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.