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
2
votes
1 answer
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 getting random UserName inside Pre-Request Scripts
I'm wanting to generate a random user to be created using the API, every time I run the request.
I have an email environment variable which I want to be set to a random email every time the user create request is sent.
I currently…
Leon W
- 123
- 1
- 5
2
votes
3 answers
get key:value pair inside sub-blocks
I have the below output from Postman or hitting end point(we can say).
{
"SearchResult": {
"total": 11,
"resources": [
{
"id": "12345",
"name": "GuestType",
"description": "Identity group ",
},
{
…
impika
- 57
- 1
- 8
2
votes
3 answers
Postman Pre-request Script for authorization bearer token
I'm trying to make script to generate my authentication bearer token for collections. so I don't have to pass token each time and I will Inherit auth from parent. But I don't know where I'm wrong in script, I'm not able to generate token and it…
nancy
- 79
- 1
- 7
2
votes
1 answer
Get redirected URL from Postman
I'm currently migrating my old website to a new one and I have just created some url redirect rules to redirect old links to their pages on the new website.
In order to test these redirect rules I'm using Postman but I can't find any way of getting…
MrPickles2009
- 77
- 10
2
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 B
- 2,008
- 4
- 17
- 40
2
votes
1 answer
Postman multiple image
I'm not able to select multiple images in postman. Is their any script using which we can select multiple image? please help
pratik kolhe
- 21
- 1
2
votes
1 answer
How to clear console of postman programmatically
I'm trying to write assertions for api testing using postman. In order to debug I'm using console.log() function, which is cluttering the console of Postman.
I've tried console.clear(); in pre-request script but get TypeError.
Error in postman:
Can…
still_breathing
- 21
- 1
- 2
2
votes
1 answer
Trying to call cognito token from postman script
Working within Postman I'm trying to call a jwtToken from Cognito using node's aws-sdk but I'm getting the following error:
There was an error in evaluating the Pre-request Script: Error: Cannot find module 'aws-sdk'
This is my scrypt:
const AWS…
Sebastian Carpaneto
- 43
- 2
1
vote
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
- 824
- 1
- 7
- 29
1
vote
2 answers
How to iterate over a JSON array and log the attributes that have a certain value
I have a response body that looks like this
{
"data_sets":[
{
"author": {
"name": "foo"
},
"category": "zip",
"client": true,
"data_type": "zip",
"index":…
Shultz
- 81
- 5
1
vote
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
- 611
- 6
- 25
1
vote
1 answer
Token in postman not able to fetch the value
I am setting the access token in my environment variable which will fetch the value from a Pre-request script that I have written and placed in my collection but when I try to run the request it gives me error saying "Message": "Response status code…
anita
- 11
- 2
1
vote
1 answer
How to chain these two Postman requests
I'm new to Postman and I am trying to automate usage of these two requests.
The first one is a POST request which returns a JSON with a single key:value pair ("id") in it
The second one is a POST request which just returns 200 OK
So far I've managed…
damnatus
- 13
- 2
1
vote
0 answers
PostMan Pre-request script for fetching JWT using Laravel
I am trying to write a pre-request script for getting JWT for my postman tests using Laravel. I tried the js code that works perfect when I use .NET REST API, but now in Laravel it is not working. If I hit the login endpoint it works I got my JWT,…
Wasyster
- 1,655
- 2
- 19
- 38