Use this tag for issues with pre-request scripts in postman, use the "postman" tag for general issues
Questions tagged [postman-pre-request-script]
319 questions
1
vote
2 answers
How to chain these two Postman requests
I'm new to Postman and I am trying to automate usage of these two requests.
The first one is a POST request which returns a JSON with a single key:value pair ("id") in it
The second one is a POST request which just returns 200 OK
So far I've managed…

damnatus
- 23
- 3
1
vote
1 answer
PostMan Pre-request script for fetching JWT using Laravel
I am trying to write a pre-request script for getting JWT for my postman tests using Laravel. I tried the js code that works perfect when I use .NET REST API, but now in Laravel it is not working. If I hit the login endpoint it works I got my JWT,…

Wasyster
- 2,279
- 4
- 26
- 58
1
vote
2 answers
Postman Pre-request Script: Need to generate a random DOB (18 years or older)
I was looking for it sometimes but could get a straight answer. I would like to have a Random Date of Birth generated in MM-DD-YYYY format and should be older than 18 years.
I looked up here the new Dynamic variables which are generated from the…

Nihir Kumar
- 283
- 1
- 6
- 19
1
vote
2 answers
Postman Pre-Requisite Script: Store Email ID based on Random First name and Last name
I am struggling here to generate an email ID that consists of Random First name and Random Last name. I don't want to use the dynamic Variable $randomEmail because it generates any random email which is totally different from the First name and Last…

Nihir Kumar
- 283
- 1
- 6
- 19
1
vote
1 answer
Insert timestamp without milliseconds (only 10 digits) in Postman
I have this in my pre-request script:
var moment = require("moment");
postman.setEnvironmentVariable("current_timestamp", moment().add(10, 'seconds').valueOf());
This returns 13 digit value for timestamp,But my server only accepts upto 10 digits…

alam mand
- 11
- 1
- 2
1
vote
1 answer
saving arrays in one call and use it in another call in postman
I am trying to use chain request feature in postman.
Here is my first request:
As you see I am trying to save configs as an array to use it in another request. Apparently post man save the array in env vars as an strings.
So here I need to use the…

Learner
- 1,686
- 4
- 19
- 38
1
vote
1 answer
Implementing Sage Intacct API via Postman
I would like to get the invoice link from the purchase order implementing Sage Intacct API via Postman.
I suppose it can be done by following sequences(or by only one api request? not sure about this).
Order a purchase
Create a purchase receipt
Get…

koko-js478
- 1,703
- 7
- 17
1
vote
1 answer
decrypting CyproJS AES encryption in Cryptodome python
I am trying to decrypt message (in python) that has been encoded using CryptoJS in JavaScript. I have created an API in python, to post data I am using postman pre-request script.
The Error I am getting:
ValueError: Data must be padded to 16 byte…

D1V
- 45
- 10
1
vote
1 answer
How to provide expected JSON (response) using external text file in Postman
I am making a collection where after hitting each API, I need to validate the response (in JSON) against my expected JSON which I have extracted after manually hitting the API first.
I already know that I can pass this expected JSON as any other…

user1710861
- 413
- 6
- 9
1
vote
1 answer
Set env variables in multiple loops using postman
I want to test the following workflow structure.
in first request script,
var st = [1,2,3]
var i = st.length;
for(var j=0; j

user1156041
- 2,155
- 5
- 24
- 54
1
vote
1 answer
How to add a external javascript file postman environment?
How to add an external javascript file postman environment? I want to use some external javascript for Pre-request Script.

Al Amin Bhuian
- 23
- 5
1
vote
2 answers
List of environments in POSTMAN
I am working on a POSTMAN collection. Say, I have two separate postman environments with each having URL variables, lets domain1 & domain2. In my initial script in pre-request tab I want to get a list of all the environments available so I can…

Maharaj
- 313
- 2
- 3
- 14
1
vote
1 answer
Postman test automation - verify json array response
I have a simple api GET request and the response body is just like below. I'm using Postman API automation and I want to validate the response and check whether below conditions are met using a Postman test.
Response array size should always be…

Prabodha
- 520
- 1
- 6
- 19
1
vote
2 answers
Postman, Set on evraibale for "run session"
I know that we can set a variable in different scopes via a pre-request script, but can we set one for on "execution" or "run of test".
I have a folder that contains two requests to validate a scenario where the first one will create a resource with…

gervais.b
- 2,294
- 2
- 22
- 46
1
vote
1 answer
Postman minute not updating after each request
In my pre-request script section I am simply doing:
const moment = require('moment');
console.log(moment().add(1,'minutes').format("YYYY-MM-DD HH:MM"));
console.log(moment().add(2,'months').format("YYYY-MM-DD HH:MM"));
Which outputs:
2020-07-29…

Elliot Reeve
- 901
- 4
- 21
- 39