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:

319 questions
0
votes
1 answer

Setting DateStart and DateEnd variables in Postman to represent 'yesterday'

I am trying to make an API call in Postman where I have to pass DateStart and DateEnd parameters. The date should be in the format yyyy-mm-ddThh:mm:ss. I tried the below but won't it just subtract 1 day from the current timestamp. var moment =…
0
votes
1 answer

Postman JSON Schema Validation fails, if an Object.prototype function declared prior to the validation

I have a schema validation test in my postman collection, which validates if the response adhere to the schema. This is how I do it. var schema = { "type": "object", "properties": { "data": { "type": "object", "properties":…
neo_er
  • 5
  • 1
  • 4
0
votes
0 answers

Replace all the id values with another set of ids in a body request in Javascript

I have one response and I have one request: Response { "questions": [ { "id": 75930, "drmsCaseId": 236, "questionId": 32, "answer": "", "questionGroup": { "key": "KYC", "value": "Know Your Client…
0
votes
0 answers

Pre test to automate the access token in Postman

I tried to automate my postman test. In first test I should get access token to execute the API call. So I write pre test below. But I am getting 'There was an error in evaluating the Pre-request Script:Error: No data, empty input at 1:1 ^'. I tried…
Testtest
  • 61
  • 1
  • 8
0
votes
1 answer

Conditioned next post cmd according to response variable

with get, I am trying to get location status from the machine by CMDs from the postman. I am sending commands for transport to defined locations. These locations have some status. This status I can get…
0
votes
2 answers

How to send a POST request (registration) in Postman using pre-request script

I'm trying to create a new user using a pre-request script to be able to use a PUT request to edit user profile settings independently from other requests. So I'm setting a token from the response to my env variable to use it in the header for the…
0
votes
1 answer

Postman. Getting "JSONError: No data" after sending Cognito token pre-request

let tokenUrl = 'https://my.url/oauth2/token'; let scope = 'pets/read pets/updage petId/read' let getTokenRequest = { method: 'POST', url: tokenUrl, header: { 'Content-Type': 'application/x-www-form-urlencoded', …
0
votes
2 answers

Disable Postman SSL certificate verification with script

TL;DR I have two questions. Is the SSL verification setting, either global or request level, available to the Postman scripting sandbox? Where is it and how to I access its value (globals.get, variables.get, etc)? I'm writing a Go/Gin based API…
drognisep
  • 579
  • 1
  • 7
  • 16
0
votes
2 answers

Postman test - error parsing JSON request with variables

My request body looks like this "pulic_token" variable is ready defined. My pre-request test looks like this: pm.test("Public token is correct", () => { const req = JSON.parse(request.data); …
ericn
  • 12,476
  • 16
  • 84
  • 127
0
votes
1 answer

How to add file in an pre-request script using form data on Postman

I am trying to create a request in the pre-request script using in the form-data and in the body i would like to upload a pdf file from my working directory. I used the following script and the file is not attached in my script. Can you please help…
0
votes
1 answer

Postman: How to set authorization type for specific environment?

In Postman I have the following configuration: I have Basic Auth permission for my collection. I have an Admin User environment. In this environment I have username and password. When I run my requests, the Admin user logs in and the request is…
0
votes
1 answer

Execute a request a given number of times (postman)

Related to: https://stackoverflow.com/questions/36157105/postman-how-to-make-multiple-requests-at-the-same-time#:~:text=Just%20create%20a%20runner%20with,to%20bring%20up%20multiple%20instances. but I need to make the same request a given number of…
0
votes
1 answer

Postman collection runner does not apply data to requests

This sounds basic but I have no clue what postman is doing; my setup is as follows: input file: [ { "url": "http://localhost:3000/gadgets/", "gadget_id": "8f338a25-c52a-4c47-9d5f-69a6c48c24f2", "user_id": "" }, { "url":…
0
votes
1 answer

How to grab variable from one API that is within a nested Array response body?

How to grab the contentID and content title add it within an array and have it used in the URL of API 2 if i use the code below for section title and sectionid it is working because it is not in an nested array but for the contentid and contenttitle…
0
votes
1 answer

Looping my data file in postman runner, can I schedule individual request from runner itself?

I am running a collection runner in a loop with data file. I have to make a hit to three apis consecutively but When the third api runs, I need to schedule another api with same request after 15 mins. How can I do this with postman? P.S= I want to…