Questions tagged [postman-pre-request-script]

Use this tag for issues with pre-request scripts in postman, use the "postman" tag for general issues

Reference:

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.…
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…
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…
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…
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…
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…
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:…
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…
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…
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…
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?
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…
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…
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…
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…
1
2 3
12 13