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
0
votes
1 answer
Not able to get values of postman global variable
I am able to set global variable but unable to get that.
pm.sendRequest(getLibraries, function (err, response) {
if(!err){
var jsonData = response.json();
console.log('Libraries: ',jsonData);
var lib_id =…

Ranjeet
- 49
- 8
0
votes
0 answers
Postman pre-request everything is working fine as expected but facing below Undefined error
There was an error in evaluating the Pre-request Script: Error: Cannot read property 'name' of undefined
var limit = 50;
pm.sendRequest(getComponentsNewURL, function (err, response) {
var jsonData = response.json();
…

Ranjeet
- 49
- 8
0
votes
0 answers
Dynamically add query parameters from an Array and iterate in Postman request
I have a scenario where I am allowed to pass maximum of 100 lat and long separated by semicolon(;) as query parameter in one API request. I got total of 100,000 lat long to pass which I need to iterate and send get request. I have tried the…

Ragavan Rajan
- 4,171
- 1
- 25
- 43
0
votes
0 answers
All the requests in a postman collection do not run
I am new to postman. I have 6 requests collection and I am using variables that pass from these requests.
In request 3 I am using the If else statement and postman.setNextRequest to ensure that the request goes in loop until I get the required…

Sreedhar Reddy
- 3
- 2
0
votes
0 answers
How to write a nested test case in postman?
For Example, if below is my response:
{
"rule":"1001",
"fixedResponse":"101JOB0011102JOB0012"
}
Based on fixedResponse field value, can I create a test case like a function within a function for each job validation?
pm.test("Validate…

Vivek Rangaraj
- 13
- 4
0
votes
2 answers
How can I use the URI module in a Postman Pre-Request Script?
I have to create an auth hash for a web api call in my Postman pre-request script. My collection stores the service URL in a collection-level variable called baseUrl. The value of this variable is http://api-server.local
Unfortunately, the baseUrl…

abjbhat
- 999
- 3
- 13
- 24
0
votes
1 answer
Set field to random number before sending request in Postman
I have a POST request in Postman.
One of the fields in the request is a price for an item.
I don't want to manually change the value and then send the request every time.
I want to generate a random value and then set it for the field. Then send…

loganrussell48
- 1,656
- 3
- 15
- 23
0
votes
1 answer
Delete Postman Cookies
Is there any way to expire authtoken in postman saved after login call?
I have tried to code get response object
{
tests["Login successfull"] = responseCode.code === 200;
var token = postman.getResponseCookie("authtoken");
console.log(token)
}
this…
0
votes
1 answer
Pre-req Postman Variables Stopped Working
I have an incredibly simple pre-request script that was working just fine on my Mac using the lastest Postman. I was sharing the workspace and Postman was constantly nagging me about not paying, and my sharing partner wasn't looking at the work so…

MJK
- 1
- 1
0
votes
1 answer
Excluding headers from code generated through Postman for a defined request?
When developing, it's oftentimes very helpful to be able to copy the requests that you are making as cURLs when presenting bugs or troubleshooting with other team members. However, when you use the Generate Code Snippets feature, it will…

Arthur
- 345
- 1
- 2
- 5
0
votes
0 answers
How to rerun same api if response is not 200
in automation postman script, how to rerun the same api if the response is 500 instead of 200, till api's response is other than 500.
pm.test("Status code should be 200 on invalid user", function () {
pm.response.to.have.status(200);
});

Riya
- 37
- 2
- 7
0
votes
0 answers
Postman Accesstoken Automatic refresh issue
I'm a newbie in postman. I'm trying to automate the process of refreshing Access token using pre-request script of postman as mentioned in the below document
Click here
Pre-request Code:
let tokenUrl =…

Jijith
- 55
- 1
- 2
- 8
0
votes
1 answer
Shufle data from array for Postman pre-request script
I am trying to create some random test data for my project, and I am trying to this with Postman pre-request script.
My problem is that I have some values in array, and I am trying to get values from them.
This is my Postmans pre-request script:
var…

Wasyster
- 2,279
- 4
- 26
- 58
0
votes
1 answer
Is there any way to store array/list as variable/parameter in constructing an API in Postman?
I'm trying to parameterize a url in Postman and loop over that list to call multiple APIs one after another and append the JSON bodies.
For example:
if the url is GET https://location/store/{{user_id}}/date
and
user_id =…

staifmis108
- 67
- 5
0
votes
1 answer
Is it possible to create postman environment scopes using pre-request in local?
I want to create postman scopes in local through pre-request. is it possible to create?

Ram
- 35
- 6