Skip to content

Instantly share code, notes, and snippets.

View rproman's full-sized avatar
🎯
Studying

Randy Roman rproman

🎯
Studying
View GitHub Profile
@rproman
rproman / Postman - Persist Environment Variables.js
Last active July 1, 2022 19:51
Programmatically persist the current values to initial values of environment variables.
let headers = {'X-Api-Key' : ''};
headers[`X-Api-Key`] = String(pm.variables.get("postman_api_key"));
// Note: Update the environment UID if no longer sync
const postman_api_url = "https://api.getpostman.com/environments/" + pm.environment.get("uid");
let requestOptions = {
url: postman_api_url,
method: 'GET',
header: headers
// generating random data
var randomData = Math.random();
// getting Auth tokens from other Auth services
pm.sendRequest({
url:"https://postman-echo.com/basic-auth",
method: "GET",
header: {
'Authorization': 'Basic ' + btoa('postman:password')
}