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

Python script from Postman Edit payload to parse string

From the Postman window I am able to write data to a database without issues using the following payload payload = "{\"Items\": [{\"SystemId\": \"FPC\",\"EngagementId\": \"40211\",\"DE_LOD_INF_LAND_LAT\":\"20.000000\",…
0
votes
1 answer

Use image from $randomImage variable in API request

I want to get an image from http://lorempixel.com using the $randomImage variable in Postman and use this in another multipart request which accepts a image/png content-type. How can I do that? I think I need to store the image in a variable but I…
user828647
  • 505
  • 1
  • 10
  • 27
0
votes
1 answer

How to use variable from one request in another request test body in postman test body?

I want to execute 3 requests (api1, api2 and api3) one after the other. I want to make api3 request dependent on values(type:int) of api1 and api2. In api1 request test body: var data = pm.response.json(); var count1 = data.length; In api2 request…
0
votes
2 answers

Run pre-request script on each API request in postman

Can this randomString(length) be reused in another pre-request script instead of having in each API request in postman? function randomString(length){ var char =''; while(chars.length < length ){ chars +=…
Lakshmi
  • 17
  • 1
  • 6
0
votes
1 answer

How to get Postman using "x-auth-token" not "Authorization" bearer?

I'm getting token from a request and I'm saving it as environment variable and would like to use it in every other request as then I don't have to manually change it. But the requests want "x-auth-token" header in the request but my token is going…
0
votes
1 answer

Postman: Read a csv file placed in aws using Postman?

How can I read a csv file placed in aws using Postman ? I am able to get list of files and folders places in aws using aws url: https://s3.amazonaws.com/partnertrackingconfigurationdev/?list-type=2 access key, secret key and session token. But, I…
0
votes
1 answer

In a Postman collection, one of the services only needs to be called once

I'm designing a fairly simple collection, with two services in the collection: Request # 1 : get token service Request #2 : service to get detailed information (needs token from previous service) I've managed to get the token from service #1 and…
0
votes
1 answer

How to fetch JWT token in postman pre-request script?

I am new to using postman to test api. I am trying to fetch a JWT token which I can save as an environment variable in postman. I was referring to this excellent post on how to do it: jwt-postman I have the below python code which I used before in…
Naxi
  • 1,504
  • 5
  • 33
  • 72
0
votes
1 answer

How to URL encode a dynamic email variable in Postman?

i just wanna know if there is a way to url encode an dynamic email variable in postman? basically i want random names in all parts of the email for my collection run. For example test1@abc.com , ybc@asd.com.(which can be solved by using the email…
0
votes
0 answers

Dynamic Basic Auth Credentials in Postman

I want to loop through different sets of credentials against a single request in the collection runner for Postman API Testing, but I'm not sure how best to dynamically set the credentials for each iteration?
0
votes
1 answer

Postman adding values to request json

Hi I am hoping this is a simple question. In my pre-request-script I am getting a JSON object back from a GET. This JSON object has 10 fields. I would like to add 2 more. I tried myJson.add and myJson.push but those don't work. How would I…
Scott H.
  • 3
  • 4
0
votes
1 answer

skip iteration based on value - postman

I am working on a postman collection where I have written two get requests for APIs. I am using a single data file in the runner for both the requests when I run. My data file looks like below - What I am trying to do is when I run request1 it…
0
votes
1 answer

How to store a request JSON in a variable and use it in the mocked response body

I want to mock exact request values in response. ex : request body {“username”:“google”, “address” : {“city”:“CA”}, “contactNo”:“8274287844” } response should be like this : based on request i need to map exact values to same key(from request to…
var a
  • 39
  • 9
0
votes
0 answers

How to read model's schema and validate in postman test script

I have a model schema and i want to read those and validate in postman test script. could you please share your suggestions ?
0
votes
1 answer

Different status responses of requests from terminal and file

From terminal the command response.status returns 200. From myfile.py the command requests.get(next_page, headers=headers) returns . I expected to get 200 from file. What can be wrong? myfile.py: import lxml.html as parser import…