Last active
April 22, 2022 16:41
-
-
Save achinta/85e5c387c68acda4358ace99d9dcf8d2 to your computer and use it in GitHub Desktop.
Postman Snippets - creating variables in pre-request script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create random variable with timestamp as suffix | |
var ts = pm.variables.replaceIn("{{$timestamp}}"); | |
pm.collectionVariables.set("name_ts", 'test ' + ts); | |
//create timestamp variables | |
var moment = require('moment'); | |
pm.collectionVariables.set('arrival_date', moment().format(("YYYY-MM-DD HH:mm:ss"))); | |
pm.collectionVariables.set('departure_date', moment().add(5, 'days').format(("YYYY-MM-DD HH:mm:ss"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment