DEV Community

Cover image for Set Environment Variables Programmatically in Postman
Abayomi Ogunnusi
Abayomi Ogunnusi

Posted on

3

Set Environment Variables Programmatically in Postman

Working with APIs, particularly those that use the JWT model for authentication, can be challenging because it requires copying and pasting the Bearer token into the Authorization headers.

The blog post explains how to reuse JSON web tokens in Postman, which will speed up your API Testing experience.

Prerequisite

Basic HTTP and RestAPI Understanding


Image description


Let's create an environment that allows us to change the context of our requests.

🎯 Select the Environment quick look option.

Image description


Click on the add button

Image description


🎯 Set the name of the Environment [green], the base URL, and click the save button

Image description


🎯 Change the Environment to the newly set one and also the baseUrl in two curly brackets

Image description


🎯 Hover over the baseUrl to see the URL referenced from the environment variables.

Image description


🎯 Following that, we set our JWT against the response token.

Image description


🎯 Try the request again, everything should still work

Image description


If you open the environment quick look section, the new JWT token should be listed as one of the variables.

Image description


🎯 To use the JWT on protected routes, follow the highlighted points.

Image description


Finally, if you open the headers tab, you will notice that the Authorization values are automatically prefilled.

Image description


Conclusion

I hope this post was useful and has shortened your API testing time. Thank you for reading.

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay