# \#pmsendrequest

**URL:** https://community.postman.com/tag/pmsendrequest/177.md

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

---

## [pm.sendRequest doesn't seem to work inside of a collection level Utility pre-request script function](https://community.postman.com/t/pm-sendrequest-doesnt-seem-to-work-inside-of-a-collection-level-utility-pre-request-script-function/81257)

<div class="topic-metadata">

**Author:** [@sbrown1005](https://community.postman.com/u/sbrown1005)\
**Replies:** 4\
**Last updated:** [June 18, 2025, 3:20pm UTC](https://community.postman.com/t/pm-sendrequest-doesnt-seem-to-work-inside-of-a-collection-level-utility-pre-request-script-function/81257 "2025-06-18T15:20:01Z")

</div>

I’m attempting to set up the below script in my test collection to enhance the flexibility of my tests. However, the utils function receives the data but the pm.sendRequest doesn’t execute. Is there a problem with my scr…

---

## [Add an external node module to postman (xml2js)](https://community.postman.com/t/add-an-external-node-module-to-postman-xml2js/23974)

<div class="topic-metadata">

**Author:** [@smals-jy95](https://community.postman.com/u/smals-jy95)\
**Replies:** 2\
**Last updated:** [April 14, 2025, 10:20am UTC](https://community.postman.com/t/add-an-external-node-module-to-postman-xml2js/23974 "2025-04-14T10:20:34Z")

</div>

Hello, I would like to use xml-js in my pre-request script so that I can do this : Parse an input xml file into a json object Make modifications on it (like add different prefixes on elements, …) Parse the json into a…

---

## [Collection variables not updating via pre-script](https://community.postman.com/t/collection-variables-not-updating-via-pre-script/76716)

<div class="topic-metadata">

**Author:** [@devteamadipsys](https://community.postman.com/u/devteamadipsys)\
**Replies:** 11\
**Last updated:** [March 11, 2025, 10:24am UTC](https://community.postman.com/t/collection-variables-not-updating-via-pre-script/76716 "2025-03-11T10:24:13Z")

</div>

Hi here ! Yesterday i have write a pre-script for my collection. I had used : pm.collectionVariables.set(‘sessionId’, response.json().sessionId); which worked great but this morning (update v11.36.1), it does not wor…

---

## [Sending Binary data via a script](https://community.postman.com/t/sending-binary-data-via-a-script/73622)

<div class="topic-metadata">

**Author:** [@cruxto](https://community.postman.com/u/cruxto)\
**Replies:** 3\
**Last updated:** [January 15, 2025, 9:04am UTC](https://community.postman.com/t/sending-binary-data-via-a-script/73622 "2025-01-15T09:04:54Z")

</div>

Hi There, I hope someone can help as I’ve spent quite a bit of time trying to resolve this with no success, I want to send a binary image to an API using the pre-request script. Firstly I tried using the standard Post…

---

## [Payload details in pm.sendRequest()](https://community.postman.com/t/payload-details-in-pm-sendrequest/64928)

<div class="topic-metadata">

**Author:** [@spacecraft-technol17](https://community.postman.com/u/spacecraft-technol17)\
**Replies:** 3\
**Last updated:** [August 2, 2024, 4:35pm UTC](https://community.postman.com/t/payload-details-in-pm-sendrequest/64928 "2024-08-02T16:35:03Z")

</div>

I need to pass the entire request payload as variable in pm.sendRequest() method.For it,I have saved the request payload in environment and got it from env. It is not working as varaibles values which are in payload…

---

## [TypeError when calling a endpoint with an async request](https://community.postman.com/t/typeerror-when-calling-a-endpoint-with-an-async-request/64440)

<div class="topic-metadata">

**Author:** [@Minhaco](https://community.postman.com/u/Minhaco)\
**Replies:** 6\
**Last updated:** [July 23, 2024, 2:22pm UTC](https://community.postman.com/t/typeerror-when-calling-a-endpoint-with-an-async-request/64440 "2024-07-23T14:22:31Z")

</div>

I’m have a script that calls an API to get a token. I saved this token in a environment variable and it was working correctly, but I don’t know why I’m getting this error: TypeError: Cannot read properties of undefined…

---

## [pm.sendRequest() execution order](https://community.postman.com/t/pm-sendrequest-execution-order/63425)

<div class="topic-metadata">

**Author:** [@spacecraft-technol17](https://community.postman.com/u/spacecraft-technol17)\
**Replies:** 5\
**Last updated:** [July 3, 2024, 1:03pm UTC](https://community.postman.com/t/pm-sendrequest-execution-order/63425 "2024-07-03T13:03:45Z")

</div>

I am having multiple pm.sendRequest() that are being kept in pre-request tab of a request. My concern is that not able to send the requests as per order. For example.Login should be first,then job creation,then task cr…

---

## [Settingup pm.sendRequest() as env variable](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694)

<div class="topic-metadata">

**Author:** [@spacecraft-technol17](https://community.postman.com/u/spacecraft-technol17)\
**Replies:** 1\
**Last updated:** [June 27, 2024, 11:01am UTC](https://community.postman.com/t/settingup-pm-sendrequest-as-env-variable/62694 "2024-06-27T11:01:20Z")

</div>

I am setting up few requests which need to be executed before certain requests of collection at pre-request script via pm.sendRequest() method. My need is to keep entire pm.sendRequest() as environment variable and wil…

---

## [How to send GET request synchronusly within loop?](https://community.postman.com/t/how-to-send-get-request-synchronusly-within-loop/61506)

<div class="topic-metadata">

**Author:** [@zdenko-s](https://community.postman.com/u/zdenko-s)\
**Replies:** 4\
**Last updated:** [May 28, 2024, 3:42pm UTC](https://community.postman.com/t/how-to-send-get-request-synchronusly-within-loop/61506 "2024-05-28T15:42:00Z")

</div>

I searched community and found answers about synchronous executions but none of them suits my needs. In my case repetition number is unknow, depends on response (or timeout). Chaining and nesting is not solution. I have…

---

## [Why is pm.sendRequest returning a function in 'response'?](https://community.postman.com/t/why-is-pm-sendrequest-returning-a-function-in-response/61013)

<div class="topic-metadata">

**Author:** [@deveshitis](https://community.postman.com/u/deveshitis)\
**Replies:** 6\
**Last updated:** [May 15, 2024, 1:31pm UTC](https://community.postman.com/t/why-is-pm-sendrequest-returning-a-function-in-response/61013 "2024-05-15T13:31:44Z")

</div>

Use case: Before making an API call, get the latest OAuth token and update it in the environment variable (async () =\> { try { //Set environment variables and encode credentials // Send POST request console.log("Bef…

---

## [I can't get the sixth element from the header array](https://community.postman.com/t/i-cant-get-the-sixth-element-from-the-header-array/59937)

<div class="topic-metadata">

**Author:** [@garibzyanovsergei](https://community.postman.com/u/garibzyanovsergei)\
**Replies:** 4\
**Last updated:** [April 15, 2024, 5:16pm UTC](https://community.postman.com/t/i-cant-get-the-sixth-element-from-the-header-array/59937 "2024-04-15T17:16:55Z")

</div>

Why I can’t get the sixth element from the header array from the response, because it’s there? I have the code in the pre-request scripts: pm.sendRequest({ url: pm.environment.get('baseUrl') + '/checkPhone', …

---

## [A pm.sendRequest from a function body in Postman doesn't work](https://community.postman.com/t/a-pm-sendrequest-from-a-function-body-in-postman-doesnt-work/25584)

<div class="topic-metadata">

**Author:** [@SBoris](https://community.postman.com/u/SBoris)\
**Replies:** 4\
**Last updated:** [March 14, 2024, 9:37am UTC](https://community.postman.com/t/a-pm-sendrequest-from-a-function-body-in-postman-doesnt-work/25584 "2024-03-14T09:37:43Z")

</div>

I’m trying to call a request from a function body in order to reuse code across a collection. But it looks like pm.sendRequest(request, function(err, response)… is ignoring. Where I’m wrong? The post is similar to this n…

---

## [Mac: not possible to add Content-Length header to pm.sendRequest](https://community.postman.com/t/mac-not-possible-to-add-content-length-header-to-pm-sendrequest/25766)

<div class="topic-metadata">

**Author:** [@DefaultPlayer](https://community.postman.com/u/DefaultPlayer)\
**Replies:** 2\
**Last updated:** [March 9, 2024, 6:54pm UTC](https://community.postman.com/t/mac-not-possible-to-add-content-length-header-to-pm-sendrequest/25766 "2024-03-09T18:54:00Z")

</div>

Hello, I am a mac user and I have request in postman (version 8.8.0 (8.8.0)) with tests in which I am repetitively sending the request. The problem is that the content-length header is not added at all. Here is how the …

---

## [Getting Unauthorized error in Send Request Test Script](https://community.postman.com/t/getting-unauthorized-error-in-send-request-test-script/55006)

<div class="topic-metadata">

**Author:** [@roopesh07](https://community.postman.com/u/roopesh07)\
**Replies:** 3\
**Last updated:** [November 26, 2023, 7:30am UTC](https://community.postman.com/t/getting-unauthorized-error-in-send-request-test-script/55006 "2023-11-26T07:30:39Z")

</div>

I have a authorization token(Bearer Token) Used in Sending API Requests there the request is getting sent and the response also been received but the same authorization token is giving me Unauthorized Response when used …

---

## [pm.sendRequest with SSE : How to access streamed events?](https://community.postman.com/t/pm-sendrequest-with-sse-how-to-access-streamed-events/54206)

<div class="topic-metadata">

**Author:** [@science-physicist-21](https://community.postman.com/u/science-physicist-21)\
**Replies:** 0\
**Last updated:** [November 2, 2023, 3:07pm UTC](https://community.postman.com/t/pm-sendrequest-with-sse-how-to-access-streamed-events/54206 "2023-11-02T15:07:51Z")

</div>

Hello, I’m testing endpoints that permit to write data throught POST requests. On success, these endpoint trigger an SSE notification on another endpoint. Steps of my test are :: :white\_check\_mark: Send the POST requ…

---

## [The header configured on pre request script is not added](https://community.postman.com/t/the-header-configured-on-pre-request-script-is-not-added/12602)

<div class="topic-metadata">

**Author:** [@yuri.vayne](https://community.postman.com/u/yuri.vayne)\
**Replies:** 6\
**Last updated:** [April 28, 2023, 2:14am UTC](https://community.postman.com/t/the-header-configured-on-pre-request-script-is-not-added/12602 "2023-04-28T02:14:26Z")

</div>

I am trying to use a pre-request to create an object then I will store an Id from that response and I will use in my main request but I am getting a status code 401 related to authentication but I added that header in th…

---

## [Executing sync requests programmatically from a pre-request or test scripts](https://community.postman.com/t/executing-sync-requests-programmatically-from-a-pre-request-or-test-scripts/14678)

<div class="topic-metadata">

**Author:** [@tmladenov\_atos](https://community.postman.com/u/tmladenov_atos)\
**Replies:** 9\
**Last updated:** [January 6, 2023, 1:54am UTC](https://community.postman.com/t/executing-sync-requests-programmatically-from-a-pre-request-or-test-scripts/14678 "2023-01-06T01:54:02Z")

</div>

Hello Postman team, We are using Postman to automate a broad number of requests. Sometimes we need to query an API programmatically, wait for its response, process it, and then proceed depending on what we have received…

---

## [How to encapsulate multiple pm.sendRequest()'s in a single test?](https://community.postman.com/t/how-to-encapsulate-multiple-pm-sendrequest-s-in-a-single-test/39629)

<div class="topic-metadata">

**Author:** [@sbettwieser](https://community.postman.com/u/sbettwieser)\
**Replies:** 4\
**Last updated:** [September 30, 2022, 4:45pm UTC](https://community.postman.com/t/how-to-encapsulate-multiple-pm-sendrequest-s-in-a-single-test/39629 "2022-09-30T16:45:25Z")

</div>

I need to verify the response of a request. In the past, I could simply make a test with a forEach loop over the data (as it is an array, and I need to check every entry). However, recently the way the requests are handl…

---

## [Trying to prevent 302 redirect when loading script via eval](https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017)

<div class="topic-metadata">

**Author:** [@Lampei](https://community.postman.com/u/Lampei)\
**Replies:** 1\
**Last updated:** [May 5, 2022, 1:45pm UTC](https://community.postman.com/t/trying-to-prevent-302-redirect-when-loading-script-via-eval/35017 "2022-05-05T13:45:33Z")

</div>

In my request, I load, via a globals variable, some javascript and do an eval on it so I can call it and set up my tests (rather than trying to include a bunch of requests from other collections and having to maintain al…

---

## [Postman throws "AssertionError" in console and Test Results pane instead of failed test](https://community.postman.com/t/postman-throws-assertionerror-in-console-and-test-results-pane-instead-of-failed-test/28216)

<div class="topic-metadata">

**Author:** [@jprealini](https://community.postman.com/u/jprealini)\
**Replies:** 1\
**Last updated:** [September 28, 2021, 5:52pm UTC](https://community.postman.com/t/postman-throws-assertionerror-in-console-and-test-results-pane-instead-of-failed-test/28216 "2021-09-28T17:52:17Z")

</div>

Hi! I have a strange case In one test, after making the main request, I have to make an extra api request to validate that the main request updated some info correctly So I go something like pm.sendRequest(SCAN\_REQUES…

---

## [Postman Pointers - How to Send Requests from Scripts using the sendRequest function](https://community.postman.com/t/postman-pointers-how-to-send-requests-from-scripts-using-the-sendrequest-function/22156)

<div class="topic-metadata">

**Author:** [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Replies:** 8\
**Last updated:** [April 5, 2021, 3:51pm UTC](https://community.postman.com/t/postman-pointers-how-to-send-requests-from-scripts-using-the-sendrequest-function/22156 "2021-04-05T15:51:54Z")

</div>

Hi Everyone, I’ve created a new video that reviews the power of pm.sendRequest, and how you can format it in a different way using the PostmanSDK. Most of you are likely familiar with this function, but there are more o…

---

## [I need to send dynamic values into the request body](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103)

<div class="topic-metadata">

**Author:** [@Balakrishna.Mandala](https://community.postman.com/u/Balakrishna.Mandala)\
**Replies:** 2\
**Last updated:** [August 31, 2020, 11:49am UTC](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103 "2020-08-31T11:49:38Z")

</div>

Hi, I am sending a request and it returns few records in response and it is displayed in page 1. I have multiple pages of response. After getting the first page response, i am printing the request body using “console.lo…

---

## [How to receive response using pm.sendRequest in a loop synchronously](https://community.postman.com/t/how-to-receive-response-using-pm-sendrequest-in-a-loop-synchronously/14154)

<div class="topic-metadata">

**Author:** [@Anton\_M](https://community.postman.com/u/Anton_M)\
**Replies:** 1\
**Last updated:** [July 16, 2020, 12:02am UTC](https://community.postman.com/t/how-to-receive-response-using-pm-sendrequest-in-a-loop-synchronously/14154 "2020-07-16T00:02:38Z")

</div>

Hello. I need to update one resource multiple times, but each update requires new token. So I need send 2 requests each loop and receive responses in exact order. Trying to use callback something like here: for (let num…

---

## [HELP | Regarding pm.sendRequest() and pm.request.url.addQueryParams()](https://community.postman.com/t/help-regarding-pm-sendrequest-and-pm-request-url-addqueryparams/13363)

<div class="topic-metadata">

**Author:** [@qaschool](https://community.postman.com/u/qaschool)\
**Replies:** 0\
**Last updated:** [June 12, 2020, 6:59pm UTC](https://community.postman.com/t/help-regarding-pm-sendrequest-and-pm-request-url-addqueryparams/13363 "2020-06-12T18:59:17Z")

</div>

Hi everyone! I would like to know if there is a solution to my problem, let me explain it: I am using the pm.sendRequest and I would like to send params that are stored in an array called ids. But I did not find throug…

---

## [Using pre-request script](https://community.postman.com/t/using-pre-request-script/12206)

<div class="topic-metadata">

**Author:** [@ghazaryan.nelli](https://community.postman.com/u/ghazaryan.nelli)\
**Replies:** 1\
**Last updated:** [April 26, 2020, 7:01pm UTC](https://community.postman.com/t/using-pre-request-script/12206 "2020-04-26T19:01:14Z")

</div>

Hi all, I have a photo upload POST request which I want to send in a “Pre-request Script” of another request. I’ve tried like this: pm.sendRequest({ url: pm.environment.get("url") + '/photos/add.json?key={{user\_key}}&i…

---

## [pm.sendRequest synchronous](https://community.postman.com/t/pm-sendrequest-synchronous/10869)

<div class="topic-metadata">

**Author:** [@entorres](https://community.postman.com/u/entorres)\
**Replies:** 0\
**Last updated:** [February 18, 2020, 5:36pm UTC](https://community.postman.com/t/pm-sendrequest-synchronous/10869 "2020-02-18T17:36:08Z")

</div>

Context: I’m trying to use ReportPortal.io and one of its agents (postman-agent) to run my Postman Collections. The postman-agent does not currently support asynchronous calls inside the tests (which a really require t…

---

## [How to send a request inside Tests?](https://community.postman.com/t/how-to-send-a-request-inside-tests/7345)

<div class="topic-metadata">

**Author:** [@batuarslan](https://community.postman.com/u/batuarslan)\
**Replies:** 2\
**Last updated:** [August 22, 2019, 12:57pm UTC](https://community.postman.com/t/how-to-send-a-request-inside-tests/7345 "2019-08-22T12:57:07Z")

</div>

I am deleting a parent object which also deletes a child object. After deletion, I need to send a get request and check 404 status inside test. How can I do that? I tried: pm.test("Child category is also deleted", funct…

---

## [Error recognizing variables](https://community.postman.com/t/error-recognizing-variables/4874)

<div class="topic-metadata">

**Author:** [@sterling.grogg](https://community.postman.com/u/sterling.grogg)\
**Replies:** 2\
**Last updated:** [April 7, 2019, 5:01pm UTC](https://community.postman.com/t/error-recognizing-variables/4874 "2019-04-07T17:01:17Z")

</div>

Solved I was able to solve this by changing the pm.env.get() to pm.variable.get and not it just works. Hope this helps anyone else but also I feel like it should be fixed. Hi, I’m attempting to setup a pm.sendrequest(…

---

## [Strip XML tags from API response using pm.sendRequest](https://community.postman.com/t/strip-xml-tags-from-api-response-using-pm-sendrequest/3115)

<div class="topic-metadata">

**Author:** [@markus.k](https://community.postman.com/u/markus.k)\
**Replies:** 3\
**Last updated:** [October 29, 2018, 8:30pm UTC](https://community.postman.com/t/strip-xml-tags-from-api-response-using-pm-sendrequest/3115 "2018-10-29T20:30:51Z")

</div>

Hello, I am writing API responses to a file using pm.sendRequest. I have set up a local server and use the script below which writes the entire XML response to the file as described here: \[https://documenter.getpostman.…

---

## [Is it possible to run multiple reqeusts in the Pre Request script before I run a PUT request?](https://community.postman.com/t/is-it-possible-to-run-multiple-reqeusts-in-the-pre-request-script-before-i-run-a-put-request/2218)

<div class="topic-metadata">

**Author:** [@zbaker\_apex](https://community.postman.com/u/zbaker_apex)\
**Replies:** 2\
**Last updated:** [August 6, 2018, 12:55pm UTC](https://community.postman.com/t/is-it-possible-to-run-multiple-reqeusts-in-the-pre-request-script-before-i-run-a-put-request/2218 "2018-08-06T12:55:45Z")

</div>

I am currently trying to run 2 POST requests in my pre-request script for a PUT request, one for Authentication and the other for POSTING dummy information to be used for the PUT request test. I am currently running into…

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