Use this tag for issues with pre-request scripts in postman, use the "postman" tag for general issues
Questions tagged [postman-pre-request-script]
189 questions
1
vote
0 answers
How to run and script graphQL request in Pre-request Script Section using Postman
I want to run and execute the GraphQL query via Pre-request script. However my code returns an error message "ReferenceError: jsonData is not Defined"
I am not sure on what is the main issue specifically on the jsonData that I am trying to…
amirazing
- 21
- 1
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
- 263
- 1
- 5
- 18
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
- 877
- 2
- 8
- 21
1
vote
1 answer
How to generate future date and time for postman request
{
"name": "IronMan",
"phone_number": "555555555",
"number_of_guest": 10,
"tables": [
2
],
"reservation_start_at": "2020-10-15T10:00:00.861873Z",
"reservation_end": "2020-10-15T11:00:00.861873Z"
}
I am stuck at…
TQJ
- 13
- 3
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
- 559
- 13
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
- 384
- 5
- 8
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
- 1,993
- 5
- 20
- 48
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
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
- 259
- 1
- 2
- 12
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
- 1,964
- 1
- 14
- 36
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
- 627
- 1
- 15
- 30
1
vote
1 answer
How to store cookie value using Postman pre-request script?
In postman, I have a pre-request scenario where I have to take a cookie value and store it in the environment variable, say csrf in my case, and use it for the API request. As shown in the image, I have 2 cookies for the domain namely XSRF-TOKEN and…
Rohit R
- 21
- 3
1
vote
0 answers
The authorization on the header is not taken into account in my pre-request script
I am trying to establish a pre-request script in postman but I get error "Full authentication is required" because when I send the authorization in the header it is not being taken into account (As I see in the console).
This is strange because when…
Gina Castaño
- 23
- 3
1
vote
0 answers
How to get collection request name at newman cli postman
I want to save my all response file with their request name. So I am finding a solution where I get the request name. Newman CLI is a command-line tool to run the postman collection but I read out all documentation and not get any solution for the…
Gajender Gupta
- 11
- 2
1
vote
0 answers
How to break a for loop when response code is 200
In the below script I am trying to break the for loop once I get the status code as 200, but requests keep happening even after receiving status code 200.
var getLibraries = host+'webcontents/libraries';
pm.sendRequest(getLibraries, function (err,…
Ranjeet
- 21
- 4