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
0 answers
Postman pre-request script to get access token from request body
I am trying to write a Postman pre-request script that will set my env variable for the token. I've taken one of my other working scripts and modified it for this type of response but am having issues.
I have a web service that returns the Auth…

Tim
- 1,249
- 5
- 28
- 54
0
votes
1 answer
Postman Prerequest Scripts keep getting "ReferenceError: [variablename] is not defined" but use pm.variables.set as defined
OK. I have been reading the Postman docs and looking at various posted examples but I cannot seem to be able to have the Postman web or windows app (v8.8.0) utilize the .set functions effectively to establish and update variables as I always get…

Tech Gadget Guy
- 1
- 1
0
votes
1 answer
Newman doesn’t see and doesn’t call a number of postman pre-requests
For some reason Newman doesn’t call a number of requests that are available in the Postman pre-request, but only the beginning and the last request. I start Run in postman - all requests in the pre-request are called, but Newman does not see…

juran
- 59
- 1
- 4
0
votes
0 answers
Resolving modified varible from Data scope
I'm using Postman's Collection Runner on Destop client with json test data file:
[{"var_name": {"key_1": 1, "key_2": 2}}]
I'd like to inject that JSON into the body for POST request. In Body section of request I've put {{var_name}} and set option…

sjakovac
- 124
- 8
0
votes
1 answer
Time Zone future date - Postman
pm.sendRequest("http://worldtimeapi.org/api/timezone/Europe/Rome", function (err, res) {
pm.globals.set("localTimeRome", res.json().datetime);
});
How to increase the number of days after reading the date from this api ?
Future date
previous…

ssryan
- 1
0
votes
2 answers
Postman chaining APIs with looping
I have 3 APIs.
API#1 - GET {{endPoint}}/event/{{customerId}}/orders
API#2 - POST {{endPoint}}/pullOrders/{{orderId}}/claims
API#3 - DELETE {{endPoint}}/pullOrders/{{orderId}}/events
Response of API#1 is a json with the orderIDs.
{
"List": [
…

ontherocks
- 1,747
- 5
- 26
- 43
0
votes
1 answer
Postman Authentication and Cookie Management
I'm looking for any tutorials or blogs related to Auth and Cookie managemnt in postman app. I'm new to Postman so need some guidance.
I'm currently testing an API that follows the following workflow.
visiting portal.site.com it redirects to…

M Khizer Javed
- 1
- 2
0
votes
1 answer
How to access the window object in Postman
I want to write a simple Pre-request Script in Postman that asks for a user confirmation if the request should really be executed.
I think about using
var confirmed = confirm("Start request?");
or
var confirmed = window.confirm("Start…

huha
- 4,053
- 2
- 29
- 47
0
votes
0 answers
Trigger/run Selenium script from Postman (or similar tool)
How could a Selenium script be triggered / run from Postman (or a similar tool) ?
More generally:
How could an external script be launched from Postman (or a similar tool) ?

Solid T.
- 11
- 1
- 7
0
votes
0 answers
Using postman desktop application, can we define a datasource?
Im using postman desktop application. Can we define a datasource there?
I know the we can define datasource in online workspace. But i dont want to use online version.
ANyone know how to add datasource for the desktop application?

Ratha
- 9,434
- 17
- 85
- 163
0
votes
1 answer
How to test the status code when key headers are valid
I wanted to test the status code if all the key headers are valid.
All I know is the Content-type key. I'm getting an error when doing this to other key headers.

Danbi
- 1
0
votes
1 answer
Problem regarding sendRequest in Postman in a for loop
I'm currently struggling with a problem regarding pm.sendRequest in Postman Pre-request script.
I'm trying to run a Request within a for loop, but something it doesn't work properly.
Pre-request Script
var numberOfCampaigns = 2; //this number can…

Paracetamol12
- 35
- 1
- 8
0
votes
1 answer
Reusing randomly generated variables like name in email
How to reuse in Postman variable's value in different variable. For example:
I've made three variables in new environment (which is selected as using):
name, with initial and current value: {{$randomFirstName}}
surname, with initial and current…

Bejkrools
- 1,129
- 2
- 17
- 38
0
votes
1 answer
Signing a request with a hmacSHA25 signature in Postman using a pre-request script for NiceHash API
I am trying to sign a request to access the NiceHash API.
Please see the requirements for signing the request here:
https://www.nicehash.com/docs/
postman.setGlobalVariable("hmac", CryptoJS.HmacSHA256(pm.request.headers, 'mySecret'));
Here is what…

Blake Rivell
- 13,105
- 31
- 115
- 231
0
votes
2 answers
Parse values in a JSON response array in Postman
I'm trying to parse the value of "id" from the JSON body response to include in an environmental variable in Postman with no success. Here is an example of the Body response.
"payload": {
"transaction": {
"amount": "1.00",
"id":…

Robert Cowie
- 45
- 6