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
0 answers

How can I make a Postman mock server return different examples?

In Postman, I wish to create a mock server that contains a request with 3 different examples of a response, each one associated to a HTTP code, so that on three successive calls, that request returns the mock responses in the given order.…
1
vote
0 answers

Postman - How to use pm.sendRequest without any cookies?

In my Postman collection, I have a pre-request script that ensures I have a valid JWT token available for authentication. It looks similar to the following (I have removed the logic of checking expiration and only fetching a new token if…
1
vote
1 answer

how to make a post in an https url ignoring the cert or passing the parameters to validate the certificate?

My code (generete by postman), through postman works normally, via powershell too. import requests url = "https://tamcmdb.tivit.com/mctwpsapi/v1/api/new?" payload={} files={} headers = {} response = requests.request("POST", url, headers=headers,…
1
vote
1 answer

Postman pre-request script login with Query Params

I want to create a pre-script in postman to login so that i can get tokens. pm.sendRequest({ url: 'https://localhost/api/login', method: 'POST', header: { 'Content-Type': 'multipart/form-data', }, body: { …
Heru Handoko
  • 79
  • 1
  • 10
1
vote
1 answer

Environment variable is not set properly during Postman Runner

I have a pre-request script that increments an enviroment variable to generate different ids each time a request is generated. Also, I have a runner that calls this request multiple times: However, I’ve noticed that during the runner the…
1
vote
1 answer

How to run a GET and a POST request from pre request tab of another request in postman?

I am in a situation where I need to run a request (lets say request C) based on the responses of request A and B. Here A is a GET & B is a POST request. Now I have tried to use pm.sendRequest twice in pre-request tab of C. But the problem I am…
TQJ
  • 65
  • 2
  • 6
1
vote
1 answer

Postman: "Invalid data type. Must be either, array, boolean, number" error

I get the following error when creating API in Postman: "Invalid data type. Must be either, array, boolean, integer, number, object or string" The error is fixed when converting the line "type": "file" to "type": "object", but I am not sure if there…
1
vote
0 answers

A pm.sendRequest from a function body in Postman doesn't work

I'm trying to call a request from a function body. But it looks like pm.sendRequest(request, function(err, response)... is ignoring. Where I'm wrong? utils = { myFunc: function(email, password) { var user_status = "none"; var…
1
vote
1 answer

POSTMAN - How to set environment value for nested object in single request?

Im trying to sign few fields and send the signed field as another field in an request.that is inside of an nested object..Im trying to setEnvironmentvariable but it is setting the same value again.. { "id" : "1234", "ref" : "REF05", "details": [ …
1
vote
1 answer

Is it possible to call another request in a request using Postman

Is it possible to call another request in a request using Postman? I have a collection named A Inside A I have a POST request named Login and a GET request named Profile Profile is dependent on Login so in Profile Pre-Request Script will need to…
1
vote
0 answers

Calculate file size of file in pre-request script in postman

How to calculate the file size of a file included in a pre-request script in postman ? (using JS or node js ) I tried to use fs module but fs.statSync is not a function is the error i get Any other workarounds for this?
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":…
user15269714
1
vote
3 answers

How to store a list of values in Postman and then pass a random value from the list in a API call?

I am new to Postman. I have dabbled with automating some of my API calls here in I set counters and randomize characters. However, I need to store a list of values (for this exercise it could be 1000 individual values) and then randomize which value…
user3369680
1
vote
2 answers

How to auto generate new Bearer Token in Postman for GCP Storage

I am trying to upload file from local to GCP bucket through cloud storage Rest API (https://storage.googleapis.com/upload/storage/v1/b) using Postman. I am using Bearer Token for authorization and running $(gcloud auth print-access-token) command on…
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…