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

Throw error message in pre request script is not working

pm.sendRequest(options, function (err, res) { if (res.code == 400) { throw new Error("Invalid"); }else{ pm.request.headers.add({ key: "Authorization", value: 'Bearer '+res.json().access_token}); …
Chand
  • 51
  • 7
0
votes
2 answers

Postman Cloud Agent Error: Can not send requests to localhost. Select a different agent

In postman web version When I send a request using get localhost:8080 it's just giving an arror. Cloud Agent Error: Can not send requests to localhost. Select a different agent. Please help me about the situation. Is there any problem with my Vs…
Ömer Koçar
  • 13
  • 1
  • 4
0
votes
1 answer

add aws signature to the postman script using pm.sendRequest

I would like to use a postman pre-fetch script to refresh my app secret from an api protected by aws signature. I am able to make a basic authentication like this. However I need an aws signature authentication var url = "https://some.endpoint" var…
Nic Wanavit
  • 2,363
  • 5
  • 19
  • 31
0
votes
0 answers

Is there any way to sending different cases for one endpoint intead of CSV or any data file in Postman?

This my Pre-request script in Postman: var requestToRun; switch (data["Condition"]) { case (1): requestToRun = [{ "test": "yusuf-klmn", "imageUrl": "", "name":"lop-kjm", "test2":…
0
votes
1 answer

Postman - how to run requests in different iterations

I have an issue about running a collection I have the following: Collection: Request 1 Request 2 Request 3 What I want: When I run collection, I want Request 1 to be executed 20 times, then after iteration 20 to run Request 2 and after Request 2 is…
0
votes
2 answers

How to send multiple requests using Postman pre request script?

In the following postman pre request script, I need to call multiple requests before I make an actual postman request. Firstly, it will call session API to retrieve the session id After session id is success only, then I need to call customer signon…
Brooklyn99
  • 987
  • 13
  • 24
0
votes
1 answer

How to set 2 collection variables in postman using pre-request script if the id's in the response body have dependency?

I'm trying to set 2 collections variables in the postman using a pre-request script by picking the id's from response body. There are two id's namely id and subId, I need to set both the id's in the collection variables only if the id is linked to…
0
votes
1 answer

I am finding difficult to do assertion on the below API response

[{ "FP": "DAV1", "SMO": false, "SP": [{ "name": "FOP1", "Exam": [{ "Marksguid": "a02dac4f-630f-4ed0-aa54-8c7044b71f2f", "apiUrl": "test1", "interval": 65, "schemaVersion":…
0
votes
1 answer

errore with messageSignature sha256 in postman (base64 is notdefined.)

I'm testing an api that i have to send in body those data acording to documentation: studentId, apiKey, timeStamp (current iso time as a string), messageSignature: apikey+studentId+timeStamp encrypted using sha256, i wrote a script to generate…
albertyaz
  • 39
  • 1
  • 2
  • 11
0
votes
1 answer

Build array dynamically with JavaScript/Postman

Looking to create a JSON response body with JavaScript/Postman as a pre-request script with some dynamic variables. The issue I'm having is dynamically generating arrays inside the array. The data I'm receving is a CSV file so the value is like so…
0
votes
2 answers

How to set sysdate variable in the .json object?

I have a post .json method where I send an object: { "targetSigningDate": "2021-09-22T21:00:00.000Z" } The "targetSigningDate" must always be 'sysdate'. Instead of manualy chaning the date, how to set sysdate into the object using pre-req. script…
0
votes
1 answer

Postman sendRequest function not sending request body

I am experimenting on auto fetch access tokens in postman using a Pre-request Script. I have the following code to make a request to fetch and update access tokens. var isExpired = pm.environment.get("token_expiration_time") const body = { …
0
votes
1 answer

SHA256 encryption on a parameter in Postman

We have 3 parameters that we need to send through the API. One of them is the "apikey" which is a code already provided, the other one is "utcTimeStamp" and the last one is the "signature". The signature consists of the result of encrypting with a…
0
votes
3 answers

How to iterate through an array in postman to change environment variables

I am trying to to loop through a set of ids to change their title. {{id}} and {{title}}. My request looks like this {{app}}/data/{{id}} The body looks like this { "title": "{{title}}" } Here is my current test code that doesn't work but more or less…
Steve
  • 197
  • 7
  • 17
0
votes
1 answer

how to get error message at return response using json in postman

how to check only one value is accepted when the request is inserted? if both values are passes then send the error message using json. Either RegNumber or Pan should be accepted. i am very new to this { "email_id": "sample@example.com", …