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
10
votes
2 answers
How to set the request body via Postman's pre-request script?
I use Postman 6.0 to send an HTTP request. To send a request, I use a pre-request script to get a token and put it into the environment so that it will be used in the succeeding requests.
The script below doesn't work because the body is not sent.…
![](../../users/profiles/2530100.webp)
richard
- 1,275
- 15
- 28
9
votes
2 answers
How to set basic authorization from environment variable in postman?
I want to set basic Authorization in Postman using environment variable. Because I have different authorization username and password for the different API calls.
I set my postman according to below:
In Authorization Tab: I've selected No Auth
In…
![](../../users/profiles/5995648.webp)
Arbaz.in
- 1,164
- 1
- 14
- 33
8
votes
2 answers
Running a request in Postman multiple times with different data only runs once
I am new to Postman and running into a recurrent issue that I can’t figure out.
I am trying to run the same request multiple times using an array of data established on the Pre-request script, however, when I go to the runner the request is only…
![](../../users/profiles/790664.webp)
BDM
- 464
- 2
- 7
- 15
8
votes
1 answer
Postman scripting: how to decode token
I'm using postman with scripting.
First, I perform a request to retrieve a oauth token.
Then, inside the 'Test' tab, I'm using postman scripting to use the received token to set a global (postman) variable.
Additionally, I would like to decode the…
![](../../users/profiles/4733027.webp)
hannes neukermans
- 8,470
- 5
- 30
- 44
5
votes
2 answers
How to change Postman environment in pre-request script?
I'm having several collections of REST queries and tests in postman, and for each collection I've created a set of environment variables.
I wish to make sure the right environment is selected before running the tests.
Is there a way to automatically…
![](../../users/profiles/10288558.webp)
Roey
- 53
- 5
5
votes
3 answers
In POSTMAN how do i get substring of response header item?
I am using postman to get response header value like below:
var data = postman.getResponseHeader("Location") . //value is "http://aaa/bbb" for example
I can print the value via console.log(data) easily.
However, what I really want is "bbb". So I…
![](../../users/profiles/1559625.webp)
user1559625
- 2,382
- 2
- 27
- 56
4
votes
1 answer
postman sendRequest use authorization from collection
I can send a request in a Postman pre-request script as seen below. What I would like to do is use the same authentication as is set in the Collection so that if the Collection changes then my sendRequest follows suite.
pm.sendRequest({
url:…
![](../../users/profiles/2050218.webp)
David Churchland
- 232
- 1
- 11
3
votes
0 answers
Postman - Access Token Retrieval using Authorisation Code grant type
I have set up a release pipeline to automatically deploy an API artefact to a particular domain, and as part of that pipeline I have introduced the execution of a postman collection via the Newman CLI, the ultimate goal that I want to achieve with…
![](../../users/profiles/6286655.webp)
Dave Morrison
- 143
- 11
3
votes
1 answer
Postman- Pass dynamic parameters to collection at run-time which is not part of response
I have created postman collection for unit testing of APIs.
I need to handle below scenario.
My second API generates OTP and sends it over email but its not part of response.
I want to pass that OTP in request body of 3rd API.
I am executing postman…
![](../../users/profiles/13238484.webp)
Jayashri Shinde
- 143
- 6
3
votes
1 answer
Postman - Cant run pm.sendRequest() in collection level pre-request script
Im using newman to run api tests after build in travis.
Im trying to limit the duplication of pre-request scripts so checked out some workarounds on how can I have pre-request-scripts at collection level.
My problem is that I dont want to run them…
![](../../users/profiles/13194031.webp)
Péter Tamás Nagy
- 31
- 3
3
votes
1 answer
How to add request parameters for a postman request in pre-script request
I want to add query parameters for my request in postman through the pre-request script. How can I do this?
![](../../users/profiles/9793021.webp)
Denise
- 490
- 1
- 8
- 19
3
votes
0 answers
How to clear HTTPS cookies with Postman's CookieJar
When using an HTTP host I am able to clear out the existing cookies for said host using the CookieJar method of .clear(‘host’). After moving to an HTTPS host, the .clear() method no longer works and the cookie persists. This method is in my…
![](../../users/profiles/12065143.webp)
Yamatoberu
- 31
- 1
3
votes
1 answer
Converting crypto hmac to crypto-js hmac string
I'm trying to take the process of converting a secret hmac string to allow me to test my api in postman. Postman comes pre-installed with cryptojs. This is the process I've got on my test server using crypto:
const crypto = require('crypto');
const…
![](../../users/profiles/2030864.webp)
Atlante Avila
- 994
- 8
- 31
2
votes
2 answers
Postman : how to rerun a subset of postman request multiple times
I have a postman request in the below order
GET Request
GET Request
POST Request
POST Request <<<
POST Request <<< Need to repeat only 4,5,6 - 10 times
POST Request <<<
POST request 4 , 5 and 6 needs to repeated (say 10 times)
I tried copy of…
![](../../users/profiles/14413527.webp)
supersrin
- 23
- 2
2
votes
1 answer
"TypeError: Cannot read property 'sigBytes' of undefined" error in pre-request CryptoJS script
I'm getting "TypeError: Cannot read property 'sigBytes' of undefined" error when running a postman collection with a cryptojs pre-request script. The pre-request script computes a hmac-sha256 signature which is also part of parameters of the main…
![](../../users/profiles/14156421.webp)
KBT
- 21
- 1
- 2