# \#pre-request

**URL:** https://community.postman.com/tag/pre-request/56.md

[Latest](https://community.postman.com/latest.md) · [Categories](https://community.postman.com/categories.md) · [Tags](https://community.postman.com/tags.md)

---

## [Postman Script Syntax Error - Unexpected token ';'](https://community.postman.com/t/postman-script-syntax-error-unexpected-token/80569)

<div class="topic-metadata">

**Author:** [@research-cosmologi12](https://community.postman.com/u/research-cosmologi12)\
**Replies:** 1\
**Last updated:** [May 29, 2025, 8:09am UTC](https://community.postman.com/t/postman-script-syntax-error-unexpected-token/80569 "2025-05-29T08:09:46Z")

</div>

Hello, Kindly assist - i try running scripts both pre request and post response but am consistenly getting the error “SyntaxError: Unexpected token ‘;’” Note that i typed the code manually and i have tried numerous oth…

---

## [Modify query param in pre-request script](https://community.postman.com/t/modify-query-param-in-pre-request-script/8880)

<div class="topic-metadata">

**Author:** [@delaneyc](https://community.postman.com/u/delaneyc)\
**Replies:** 9\
**Last updated:** [February 27, 2025, 7:45pm UTC](https://community.postman.com/t/modify-query-param-in-pre-request-script/8880 "2025-02-27T19:45:01Z")

</div>

I need to programmatically set a query parameter on my request. Up until a week or two ago I was able to do the following, and it worked: //url: env.com/path?param1 // update param1 to new value let queryParam1 = 'what…

---

## [Access expanded request.url and .body in pre-request script](https://community.postman.com/t/access-expanded-request-url-and-body-in-pre-request-script/1593)

<div class="topic-metadata">

**Author:** [@tporterfield](https://community.postman.com/u/tporterfield)\
**Replies:** 4\
**Last updated:** [November 20, 2024, 10:18pm UTC](https://community.postman.com/t/access-expanded-request-url-and-body-in-pre-request-script/1593 "2024-11-20T22:18:38Z")

</div>

In my pre-request script I want to access the full request.url and request.body (backstory is a hash algorithm will be run over those). I am also using environment variables in my request builder. In my pre-request scr…

---

## [Update hostname and port before real request](https://community.postman.com/t/update-hostname-and-port-before-real-request/70927)

<div class="topic-metadata">

**Author:** [@aerospace-geoscient4](https://community.postman.com/u/aerospace-geoscient4)\
**Replies:** 1\
**Last updated:** [November 7, 2024, 9:00am UTC](https://community.postman.com/t/update-hostname-and-port-before-real-request/70927 "2024-11-07T09:00:01Z")

</div>

Now, many companies use microservices to manage their applications. Each microservice may exist in multiple environments. They use the registry to register these services, such as eureka, console, etcd, etc. I hope to u…

---

## [Collection variable doesn't update in Postman](https://community.postman.com/t/collection-variable-doesnt-update-in-postman/61170)

<div class="topic-metadata">

**Author:** [@marigen00](https://community.postman.com/u/marigen00)\
**Replies:** 5\
**Last updated:** [May 20, 2024, 1:43pm UTC](https://community.postman.com/t/collection-variable-doesnt-update-in-postman/61170 "2024-05-20T13:43:45Z")

</div>

Greetings! I’ve got pre-requests with 2 pm.sendRequest. One of them depends on variable from first response. They work with setTimeout. //I set Timeout because updateInfoRequest needs to wait and get it from h2hReques…

---

## [Flow & PreRequest CryptoJS.enc.Base64](https://community.postman.com/t/flow-prerequest-cryptojs-enc-base64/60220)

<div class="topic-metadata">

**Author:** [@kochva](https://community.postman.com/u/kochva)\
**Replies:** 3\
**Last updated:** [May 16, 2024, 3:27am UTC](https://community.postman.com/t/flow-prerequest-cryptojs-enc-base64/60220 "2024-05-16T03:27:03Z")

</div>

Hi everybody! Findout this great tool “Postman Flows”, but got problem with it. I tried to use this in my project, set up authorisation chain, but i got stuck in send next request after authorisation. In normal ways i…

---

## [Retrieve values from a file for pre-request](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095)

<div class="topic-metadata">

**Author:** [@JavierReyes](https://community.postman.com/u/JavierReyes)\
**Replies:** 1\
**Last updated:** [April 18, 2024, 5:51pm UTC](https://community.postman.com/t/retrieve-values-from-a-file-for-pre-request/60095 "2024-04-18T17:51:53Z")

</div>

Hi! I’m running via a “runner” and need to retrieve a value from the input file .csv to manipulate it before the final execution. My file has this information: rut,data 103023440,4455005039211100 103023440,445528503…

---

## [Run the collection using array of objects properties as variables](https://community.postman.com/t/run-the-collection-using-array-of-objects-properties-as-variables/39048)

<div class="topic-metadata">

**Author:** [@harutharut](https://community.postman.com/u/harutharut)\
**Replies:** 7\
**Last updated:** [November 20, 2023, 8:57pm UTC](https://community.postman.com/t/run-the-collection-using-array-of-objects-properties-as-variables/39048 "2023-11-20T20:57:41Z")

</div>

Hello community, I need some help. Below is attached my code, the problem is accessing to array’s objects properties and using them as variables. I have generated an array of objects. It is big array and I should run t…

---

## [Stop request after throwing exception in pre-request](https://community.postman.com/t/stop-request-after-throwing-exception-in-pre-request/390)

<div class="topic-metadata">

**Author:** [@stealth.pda](https://community.postman.com/u/stealth.pda)\
**Replies:** 1\
**Last updated:** [November 3, 2023, 4:05pm UTC](https://community.postman.com/t/stop-request-after-throwing-exception-in-pre-request/390 "2023-11-03T16:05:21Z")

</div>

i trying to get some information in pre-request script in call another api. and i checking response and want to stop request if throw exception. now i receiving message but my request could not to stop and i sent reques…

---

## [Stop request from sending if pre-request test fails](https://community.postman.com/t/stop-request-from-sending-if-pre-request-test-fails/2066)

<div class="topic-metadata">

**Author:** [@cocovan](https://community.postman.com/u/cocovan)\
**Replies:** 10\
**Last updated:** [November 3, 2023, 4:03pm UTC](https://community.postman.com/t/stop-request-from-sending-if-pre-request-test-fails/2066 "2023-11-03T16:03:47Z")

</div>

Is there any way to prevent the request from sending due to a failed test in the pre-request script? I’ve tried making the test a function and returning false, postman.setNextRequest(null) (which didn’t seem to even set…

---

## [Pre-request async code doesn't wait for execution](https://community.postman.com/t/pre-request-async-code-doesnt-wait-for-execution/44366)

<div class="topic-metadata">

**Author:** [@ahussain.ned](https://community.postman.com/u/ahussain.ned)\
**Replies:** 2\
**Last updated:** [October 3, 2023, 2:07am UTC](https://community.postman.com/t/pre-request-async-code-doesnt-wait-for-execution/44366 "2023-10-03T02:07:43Z")

</div>

Hi, One of my requirement is to call an async login API as a pre-request script in Postman windows client. Through this code I want to set the collection variable (jwt-token). The problem is that Postman doesn’t wait fo…

---

## [Environment variable does not resolve in pre-request script](https://community.postman.com/t/environment-variable-does-not-resolve-in-pre-request-script/2659)

<div class="topic-metadata">

**Author:** [@techierik](https://community.postman.com/u/techierik)\
**Replies:** 6\
**Last updated:** [August 20, 2023, 9:46am UTC](https://community.postman.com/t/environment-variable-does-not-resolve-in-pre-request-script/2659 "2023-08-20T09:46:28Z")

</div>

Hi, Looks like environment variables specified as {{env\_var}} in URL or request body are NOT resolved before the pre-request script is run. I am trying to write a pre-request script which will parse the URL to pick up …

---

## [How can I create a dynamic requestbody using a pre-requisite script?](https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611)

<div class="topic-metadata">

**Author:** [@sergeasmar](https://community.postman.com/u/sergeasmar)\
**Replies:** 1\
**Last updated:** [August 16, 2023, 11:00am UTC](https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611 "2023-08-16T11:00:33Z")

</div>

I want to create a dynamic requestbody through a pre-requisite script. I want that script to extract the headers from the csv datafile and add them to the requestbody. I want to do this so that my code can be as reusable…

---

## [Change request body in pre-request script](https://community.postman.com/t/change-request-body-in-pre-request-script/24566)

<div class="topic-metadata">

**Author:** [@docking-module-geol4](https://community.postman.com/u/docking-module-geol4)\
**Replies:** 6\
**Last updated:** [June 26, 2023, 11:48am UTC](https://community.postman.com/t/change-request-body-in-pre-request-script/24566 "2023-06-26T11:48:20Z")

</div>

I am doing body level encryption in the pre-request script and want to the replace the entire reuqest body with encrypted data before sending the actual request

---

## [Why can't (How can) PRE-REQUEST support {{variable}} in request-line / request-body?](https://community.postman.com/t/why-cant-how-can-pre-request-support-variable-in-request-line-request-body/7595)

<div class="topic-metadata">

**Author:** [@medsonkissinger](https://community.postman.com/u/medsonkissinger)\
**Replies:** 10\
**Last updated:** [June 23, 2023, 3:15pm UTC](https://community.postman.com/t/why-cant-how-can-pre-request-support-variable-in-request-line-request-body/7595 "2023-06-23T15:15:59Z")

</div>

Please search for related topics, and then read through the guidelines before creating a new issue. Describe the bug Why can’t (How can) PRE-REQUEST support {{variable}} in request-line / request-body ? To Reproduce …

---

## [Get raw body response in pre-request script from request in pre-request script](https://community.postman.com/t/get-raw-body-response-in-pre-request-script-from-request-in-pre-request-script/44073)

<div class="topic-metadata">

**Author:** [@galex5445](https://community.postman.com/u/galex5445)\
**Replies:** 3\
**Last updated:** [February 17, 2023, 10:55am UTC](https://community.postman.com/t/get-raw-body-response-in-pre-request-script-from-request-in-pre-request-script/44073 "2023-02-17T10:55:26Z")

</div>

Hello! How can I get raw body response in pre-request script from request in pre-request script? For example: Pre request script const req = { url: 'http://www.google.com', method: 'GET' }; pm.sendRequest(req…

---

## [Run request inside another single request as pre-request](https://community.postman.com/t/run-request-inside-another-single-request-as-pre-request/41611)

<div class="topic-metadata">

**Author:** [@dmk123](https://community.postman.com/u/dmk123)\
**Replies:** 1\
**Last updated:** [November 30, 2022, 1:51pm UTC](https://community.postman.com/t/run-request-inside-another-single-request-as-pre-request/41611 "2022-11-30T13:51:12Z")

</div>

Issue: Can’t find a way to run request inside another request without running the whole collection. I want to be able to call a request from the same collection as a pre-request script inside another request without run…

---

## [Make logging and tests results easy with custom pm functions](https://community.postman.com/t/make-logging-and-tests-results-easy-with-custom-pm-functions/33614)

<div class="topic-metadata">

**Author:** [@rtfmoz2](https://community.postman.com/u/rtfmoz2)\
**Replies:** 14\
**Last updated:** [November 26, 2022, 2:47am UTC](https://community.postman.com/t/make-logging-and-tests-results-easy-with-custom-pm-functions/33614 "2022-11-26T02:47:59Z")

</div>

Go from this… Pre-Request Script // Clear env vars at start of run names = \[ "access\_token", "refresh\_token", "oid\_token", "resumeURL", "loginURL", "auth\_code", "opentoken" \]; for (index in names) { if (obj.hasOwnProper…

---

## [Change body between predefined values](https://community.postman.com/t/change-body-between-predefined-values/40601)

<div class="topic-metadata">

**Author:** [@shaga85](https://community.postman.com/u/shaga85)\
**Replies:** 6\
**Last updated:** [November 1, 2022, 2:26pm UTC](https://community.postman.com/t/change-body-between-predefined-values/40601 "2022-11-01T14:26:19Z")

</div>

Hello there! Is there a way to change a body between predefined values everytime i run a POST request? For example: { "id": 11, "name": "Tutorialspoint", "username": "Test1", "email": "abc@gmail.com", …

---

## [Pre-request script to get access token from Dropbox APIs](https://community.postman.com/t/pre-request-script-to-get-access-token-from-dropbox-apis/39893)

<div class="topic-metadata">

**Author:** [@coco2020](https://community.postman.com/u/coco2020)\
**Replies:** 3\
**Last updated:** [October 14, 2022, 7:40pm UTC](https://community.postman.com/t/pre-request-script-to-get-access-token-from-dropbox-apis/39893 "2022-10-14T19:40:14Z")

</div>

Hello, I’m new to Postman and API Testing. I’m trying to create a pre-request script to get access token automatically for a Postman collection using Dropbox APIs. However, it didn’t work well. From what I understand, f…

---

## [Is there a way to define test dependency?](https://community.postman.com/t/is-there-a-way-to-define-test-dependency/38766)

<div class="topic-metadata">

**Author:** [@alekdavis](https://community.postman.com/u/alekdavis)\
**Replies:** 9\
**Last updated:** [September 11, 2022, 9:21pm UTC](https://community.postman.com/t/is-there-a-way-to-define-test-dependency/38766 "2022-09-11T21:21:01Z")

</div>

Is there a way to specify test dependency when you execute a single test? For example, say, you have tests A and B. Test A is sets up a variable that test B requires, so test B cannot be called as a stand-alone test, but…

---

## [Creating and using variables between two pre-req posts](https://community.postman.com/t/creating-and-using-variables-between-two-pre-req-posts/38896)

<div class="topic-metadata">

**Author:** [@jon\_Alvarez](https://community.postman.com/u/jon_Alvarez)\
**Replies:** 3\
**Last updated:** [September 8, 2022, 8:26am UTC](https://community.postman.com/t/creating-and-using-variables-between-two-pre-req-posts/38896 "2022-09-08T08:26:09Z")

</div>

I’m trying to run 2 POST requests to my API within the Pre-Req script. Between the first and second POSTs, I need a value to be captured and used in the next POST. The first POST will return a value in the response that …

---

## [How do I use the requestID (GUID) in setNextRequest() in the pre-request scripts?](https://community.postman.com/t/how-do-i-use-the-requestid-guid-in-setnextrequest-in-the-pre-request-scripts/25216)

<div class="topic-metadata">

**Author:** [@award-bounteous](https://community.postman.com/u/award-bounteous)\
**Replies:** 2\
**Last updated:** [August 6, 2021, 7:05pm UTC](https://community.postman.com/t/how-do-i-use-the-requestid-guid-in-setnextrequest-in-the-pre-request-scripts/25216 "2021-08-06T19:05:48Z")

</div>

I have a specific request’s GUID that I’d like to use in setNextRequest(). When I send setNextRequest("1212121-df111f22-11f2-1212-1db2-1b0c21dacaab") (but like, the real one), it does not function. Postman runner cannot…

---

## [Change request body (RAW JSON) dynamicalls](https://community.postman.com/t/change-request-body-raw-json-dynamicalls/2043)

<div class="topic-metadata">

**Author:** [@prasu.eng123](https://community.postman.com/u/prasu.eng123)\
**Replies:** 16\
**Last updated:** [December 13, 2021, 7:42am UTC](https://community.postman.com/t/change-request-body-raw-json-dynamicalls/2043 "2021-12-13T07:42:43Z")

</div>

Hi , the json body of my request keeps changing every now and then , I have over 20 to 30 collections which will use that particular request , is there a way i can change the request body from pre request script ? or any…

---

## [Do pre-request scripts also inherit authorization?](https://community.postman.com/t/do-pre-request-scripts-also-inherit-authorization/15188)

<div class="topic-metadata">

**Author:** [@AndyG72](https://community.postman.com/u/AndyG72)\
**Replies:** 4\
**Last updated:** [December 10, 2021, 4:37pm UTC](https://community.postman.com/t/do-pre-request-scripts-also-inherit-authorization/15188 "2021-12-10T16:37:12Z")

</div>

Good morning, I am running some requests that all inherit authorization (OAuth) from the man collection which works well. But my authorization does not appear to inherit when performing pm.sendRequests in pre-request s…

---

## [How do I access request body in pre-request test script with values assigned to variables in request body?](https://community.postman.com/t/how-do-i-access-request-body-in-pre-request-test-script-with-values-assigned-to-variables-in-request-body/30451)

<div class="topic-metadata">

**Author:** [@crescent-sushant](https://community.postman.com/u/crescent-sushant)\
**Replies:** 1\
**Last updated:** [December 8, 2021, 3:11pm UTC](https://community.postman.com/t/how-do-i-access-request-body-in-pre-request-test-script-with-values-assigned-to-variables-in-request-body/30451 "2021-12-08T15:11:32Z")

</div>

How do I access request body in pre-request test script with values assigned to variables in request body? right now when I do: var body = pm.request.body.raw; console.info(“request body:”+body ); In console I see: …

---

## [How to send a request multiple times with different data?](https://community.postman.com/t/how-to-send-a-request-multiple-times-with-different-data/11157)

<div class="topic-metadata">

**Author:** [@anna.tirshenko](https://community.postman.com/u/anna.tirshenko)\
**Replies:** 16\
**Last updated:** [August 9, 2021, 6:17pm UTC](https://community.postman.com/t/how-to-send-a-request-multiple-times-with-different-data/11157 "2021-08-09T18:17:17Z")

</div>

Hello everyone! I want to have a collection which will contain a request. I want that request to be sent 3 times when running with Postman runner and each time with different data. This is my example, but when I run w…

---

## [Newman doesn't see and doesn't call a number of postman pre-requests](https://community.postman.com/t/newman-doesnt-see-and-doesnt-call-a-number-of-postman-pre-requests/25846)

<div class="topic-metadata">

**Author:** [@tester87](https://community.postman.com/u/tester87)\
**Replies:** 0\
**Last updated:** [July 16, 2021, 8:44pm UTC](https://community.postman.com/t/newman-doesnt-see-and-doesnt-call-a-number-of-postman-pre-requests/25846 "2021-07-16T20:44:08Z")

</div>

For some reason Newman doesn’t call a number of requests that are available in the Postman pre-request, but only the beginning and the last request. I start Run in postman - all requests in the pre-request are called, bu…

---

## [Need Previous month last date in variable](https://community.postman.com/t/need-previous-month-last-date-in-variable/25901)

<div class="topic-metadata">

**Author:** [@bhaskervade](https://community.postman.com/u/bhaskervade)\
**Replies:** 2\
**Last updated:** [July 21, 2021, 3:14pm UTC](https://community.postman.com/t/need-previous-month-last-date-in-variable/25901 "2021-07-21T15:14:18Z")

</div>

Hi Team, can anyone help me - pre-request script In my GET request when I ever hit the call date should be previous month last date, date parameter stored in a variable the same request runs daily to make sure it sho…

---

## [How to retrieve aws session token from pre-request script in Postman?](https://community.postman.com/t/how-to-retrieve-aws-session-token-from-pre-request-script-in-postman/7301)

<div class="topic-metadata">

**Author:** [@Johannesc2019](https://community.postman.com/u/Johannesc2019)\
**Replies:** 1\
**Last updated:** [March 22, 2021, 2:06pm UTC](https://community.postman.com/t/how-to-retrieve-aws-session-token-from-pre-request-script-in-postman/7301 "2021-03-22T14:06:55Z")

</div>

I’m looking for a way to retrieve the aws session token by writing a pre-request script. What is the recommended way of doing it?

[Next page](https://community.postman.com/tag/pre-request/56.md?match_all_tags=true&page=1&tags%5B%5D=pre-request)
