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
3
votes
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
- 41
- 1
- 3
3
votes
2 answers
Load testing an API which uses oauth token for authorization using loadimpact k6
I'm trying to load test an API (GET method) using loadimpact k6 which requires oauth token for authorization to get the successful response. I already have a postman collection file which does this by running pre-request script. The pre-request…

Nemesis
- 113
- 2
- 10
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
Stop a test running in the pre-request script but not stop the whole test run
Is it possible to stop a test running in the pre-request script but not stop the whole test collection running?
I have seen various posts mentioning these ways:
postman.setNextRequest(null);
throw new Error("Error");
These will stop the test from…

Chris
- 3,113
- 5
- 24
- 46
3
votes
2 answers
How can I create a dynamic variables in Postman for further access?
I log in, then get the token. I stored that varibale and use it throughout my next collections.
let location = pm.response.json().location
let token = location.split("?token=")[1]
console.log('Token : ',token );
When I get the token, I can use that…

code-8
- 54,650
- 106
- 352
- 604
3
votes
1 answer
Postman test script: what version of JavaScript
what version of JavaScript is allowed in Postman test script?
I tried to look this up from Postman's document but the answer is not obvious. For example, I looked at the official document of Postman Sandbox Execution Environment

leeyuiwah
- 6,562
- 8
- 41
- 71
2
votes
3 answers
Shopee API v4 server refused to respond
I am learning web crawler
I use postman as a tool
Currently practicing on the shopee website
I try to intercept "add to cart" and "checkout" posts
and send the complete duplicate post in one go
At first it was smooth
Every request I make will be…

可兒本舖
- 21
- 1
- 3
2
votes
0 answers
Postman datadriven tests
We are doing some assertion checks in Postman. For doing so, we created a collection which is having set of Api's . Now, in order to perform data driven tests , we created a excel file.
Here comes an issue when we run the collection through excel .…

Pooja Chopra
- 21
- 1
2
votes
1 answer
How to add comments in Postman JSON body (for collection level pre-request script)
I want to use comments within my JSON body for quick references like this:
{
/**
* some param info
* param: [
* 1 = value so
* 2 = value that
* ]
*/
"param": [
1
],
/* some param2 info */
…

Theo
- 2,262
- 3
- 23
- 49
2
votes
1 answer
Access cookie in pre request script in postman v8
I am trying to get the cookies in the pre request script to chain it with other request which returns as empty array using the example below.
With the latest release of postman v8, the cookies object cannot be fetched using the pm.sendRequest which…

girish
- 305
- 3
- 16
2
votes
0 answers
Postman Tests: expect on SSL certificate expiry date
Is it possible to use Postman Monitors to check how many days the SSL certificate has left before it reaches its expiration date?
When creating a request in Postman it is possible to see a popup called "Network". It contains information such as TLS…

YnkDK
- 681
- 9
- 26
2
votes
1 answer
pm.request.url.toString() with value of env var instead of the placeholder
If request is using an environment variable then when using pm.request.url.toString() inside a Pre-requisite Script it outputs the query with the placeholder and not it's actual value.
meaning it will output…

poopa
- 31
- 1
2
votes
0 answers
Postman Mock Server matching algorithm logic for request body param form-data
Is there any option to send mock results depends on form data body value in postman?
I am sending some value in the body as form data and I have two example result and now the mock API return only one example I need to get the result based on the…

Midhilaj
- 4,905
- 9
- 45
- 88
2
votes
2 answers
Postman Variables
I am trying to parse "Id" from below json to store it in a variable
{
"cf35864e-944d-11e9-8aff-22000ab8d684": {
"Id": "1a45b704-944e-11e9-8aff-22000ab8d684",
"Name": "Test plan",
"Type": "Limited",
"Credits":…
2
votes
1 answer
Postman pre-request-script URL not defined
I have a pre-request-script in Postman which need to create URL:
var uri = new URL(request.url).pathname;
console.log("uri:" + uri);
Which failed with error: URL is not defined. I searched around and tried all different ways:
//const url =…

user468587
- 4,799
- 24
- 67
- 124