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

Parse JSON response for field values

I'm using Postman to query an API for a list of users in a group. The JSON response includes a field called "created_at": "2022-05-16T18:07:09Z". { "user": [ { "id": 12345, "first_name": "Sample", "last_name": "Person", …
0
votes
1 answer

Postman - access URLs from collection in a scrip

I want to chain some requests in order to always have an up to date variable containing a JWT for access. Now i am new to scripting in Postman, i figured this can be done in pre-request scripts. There i can access (global / environment) variables,…
0
votes
1 answer

How to use Faker-variables in a pre-request-script in Postman?

PostMan supports faker-library and provides several variables like "randomFirstName" and so on. However, I try to make them work in a pre-request script. I've found a blogpost about this topic telling that it actually should…
itinance
  • 11,711
  • 7
  • 58
  • 98
0
votes
0 answers

Postman Request Chaining by Setting Next-Token Header Variable

I have a GET Request that returns a fixed paginated number of results. To process all of the pages, I would need to use the available X-Next-Token. I have the X-Next-Token set as a an empty variable in the environment. In Postman's Tests Section, I…
Hofbr
  • 868
  • 9
  • 31
0
votes
1 answer

How can I add 1 to string value in each following request in Postman

I create users for the DB. I need to send name and email. They should be unique, but not random. For example, the first user: { "Name": "Panda", "Email": "pandaemail@test.com" } Then I need run collection with this request and automatically…
Tanya
  • 1
  • 2
0
votes
1 answer

Postman returns [object object ] and value is not passing

I'm working with postman automation There is a vehicles array in the body { "Vehicles":[ { "car":"{{car}}", "bike":"{{bike}}" } ] } I need to change this like below { "Vehicles":"[{{vehicles}}]" } So I have…
0
votes
1 answer

Call a function in a Postman request

I need to call a function that returns the current date. I have to call this function in an object (contained in the body of my query). This object has a property whose value is the current date. I wrote the function code as follows in the…
Olivier
  • 343
  • 2
  • 16
0
votes
1 answer

How do I invoke a postman-defined request within a postman pre-request script?

All examples I've seen of calling a REST API within a Pre-Request script use the http API pm.sendRequest(). I'd much rather 'submit' a request that is defined through the Postman UI. Then, the request details can easily be managed through the…
MarkE
  • 123
  • 8
0
votes
1 answer

How to show value from response body when test fails

I'm new to writing pre-request script and tests in Postman. So, I wonder if there's possible to make show the value from response body when the tests fail. This is the example of the error response body and I want the test result to "FAIL" and show…
0
votes
1 answer

Attempting to put a delay in a loop in Postman

I'm trying to put a 1 second delay using setTimeout(()=>{},1000) in the Pre-request Script for a Postman POST call. var moment = require('moment'); var tap1TimeStr = pm.environment.get("now"); var tap1TimeMoment =…
Hazel Chua
  • 23
  • 1
  • 5
0
votes
1 answer

Postman - reuse the token

how I can reuse the token from one collection to another in postman? So i can run in parallel multiple folders I tried storing and reusing but haven't succeeded pm.environment.set("token", responseBody.access_token);
0
votes
1 answer

How can I reuse a parameterized Postman test across endpoints?

In Postman, I can create a set of common tests that run after every endpoint in the collection/folder Tests tab, like so: pm.test("status code is 200", function () { pm.response.to.have.status(200); }); But how should I do this for my schema…
Sasgorilla
  • 2,403
  • 2
  • 29
  • 56
0
votes
1 answer

How to by pass Javascript check while hitting an URL in Postman or HttpLibrary?

I'm trying to hit an URL and upon hitting that I will hit consecutive URLs. Both in Postman and Ruby (I'm using NET HTTP), I'm getting an error saying, "enable Javascript for website to function properly". But in browser, everything works fine. In…
sofs1
  • 3,834
  • 11
  • 51
  • 89
0
votes
1 answer

Create multiple records using JSON in Postman

I want to create 100 driver entries in my DB, for which I am using postman and automating the creation using JSON and json expects a unique driver_number every-time a POST request goes. I can do that same using JMeter but wanted to explore…
0
votes
1 answer

Run multiple Pre-request scripts sequentially in postman

I have created a postman collection consisting of around 80-100 requests. And I have categorized them in 5 separate folders. Each folder has its own functionality. I want the multiple pre-request scripts to be run sequentially for the specific…