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
1
vote
2 answers

Postman is seemingly ignoring my POST in the pre-request

I am trying to set up a DELETE call, but to do this I first need to create the data to delete so I am trying to call a POST in the pre-request. I have run the POST as a normal request and it works fine, but inside the pre-request it just seems to be…
Northers
  • 85
  • 1
  • 13
1
vote
1 answer

How do I save the response body from one request and use it in another request with some changes in Postman

I have a GET request to OKTA to retrieve some information that uses some variables etc. It returns a body. I have a second request of type PUT where I manually paste the BODY and make a change to one variable. I am trying to determine if I can…
jeyyu2003
  • 47
  • 2
  • 7
1
vote
1 answer

Postman - Selective run of API Requests within the same Iteration

I have a set of the API Requests (which are saved under the same folder). I need to execute those multiple times, based on the iterations # specified in the Runner. But there is one (the very first) request which needs to be executed only once for…
KVN
  • 863
  • 1
  • 17
  • 35
1
vote
1 answer

Receive Callback request inside Postman automated test

I am trying to write automated tests with Postman. I am new to postman automation world so sorry if the question will seem dumb. In the api that I need to test when I send a request I immediately receive a response with a transactionID, no matter…
Andranik
  • 2,729
  • 1
  • 29
  • 45
1
vote
1 answer

How to use response assertion in postman by using " to.be"?

I am trying to validate the positive and negative test cases using response assertion, but it didn't give me the expected result. I am trying to confirm the response using "pm.response.to.be.ok" to get the response as "200" an so on as listed in…
1
vote
0 answers

How to download csv file using postman from SSO protected end point?

Hey guys is there any way to fetch a file using POSTMAN from external cloud environment which is SSO(Single Sign-On) protected. because when I hit the URL in the browser it asks me to log in, then I can access that API to download the file but the…
1
vote
1 answer

Why does PostMan always show "too many errors" after 100 lines of code?

Im quite confused about an error message in the PostMan Code-Editor. It becomes visible after 100 lines of code: e.g. tests["good test"] = true; //written 100 times Postman displays a warning marker on line 100: On mouseover, this error message is…
1
vote
1 answer

how to write a test to match for data in array within postman test

I have created a variable called values, this value contains an array below: var values = ["A","B", "C","D","E","F"] I want to write a test to match json response data to one of the values in values. var jsonData = pm.response.json(); pm.test("risk…
1
vote
0 answers

How to reference a file from a pre-request script or a test script in Postman?

Problem Description: I have a file containing json schema. I want to use the schema to validate multiple collections in Postman. I want to be able to reference this file from a pre-request script or test-script. What I've tried so far: Globals/Data…
1
vote
1 answer

How to pass variable with constant value in Json postman request?

{{partnerOrderId}}- is Prerequest script through created value and considering this value as - 23457891 I have created partnerOrderId using this code: const partnerOrderId = Math.floor((Math.random()*333333333)) pm.globals.set("partnerOrderId",…
1
vote
1 answer

Postman: MD5 validation failed when passing environment variables in body

I'm trying to run a request that uses the request body for md5 encryption. When I'm using an environment variable in my body using {{var}} format I get an MD5 validation error whereas hardcoding the variable into the request body works. Is there any…
1
vote
2 answers

Pre request script of upload file with multipart/form-data hitting method 2 times in Postman

I'm working with API project and writing test cases with Postman for automation to check API status. Here I have one upload method in which user has to upload a file to the server and need to check if the server returns an appropriate…
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
0
votes
1 answer

How to set an accessToken in postman by passing the credentials in newman

I have a pre-request Script in my postmancollections.json file which does the following: const executedOnce = pm.environment.get('executedOnce'); if(executedOnce == 0) { console.log("Getting Access Token"); const tokenUrl =…
0
votes
2 answers

Extract value of a dynamic key from response

I have a response as below: { "value": { "element-6066-11e4-a52e-4f735466cecf": "b721a18e-ffab-49bc-acdf-5a30c84e160d" } } I want to extract the value of they dynamic key labelled "element-6066-xxxx-xxxx-xxxxxxxxx" (changes each…
Stephen
  • 13
  • 5
0
votes
1 answer

How to use variables from input data file(json file) for a postman collection while running using newman

I have a input data sheet in json format I want to pick the values name and passsword from this sheet and pass it in the request body of a postman request using pre-request script. This is the input sheet : [ { "num_of_steps": "1", …