Cannot read properties of undefined (reading setNextRequest)

I am working with the collection in this video It worked so I decided to use it to run a collection. I thought by using setNextRequest() I would be able to run another request I included in another collection folder. So I put this code in the post-response script of the “Echo the payload” request.

// stop the collection run

pm.test("Status code is 200", function () {;

console.log("hello from the Test Script!", pm.collectionVariables.get("webhookData"))

console.log("about to run Step 1.");


I am using the request ID because the request name is too long. Let’s call that request as “Step 1”.

this is how my collection looks like. Folder names were removed for security reasons.


Calling the Step 1 request alone, works perfect, it creates something in the system and I get an Id. That is the result I want at this moment. I want the “Echo the payload” request to hand over to “Step 1”.

What I want is that when I call the webhook, and it sends the payload, the “echo the payload” request catches some data and calls the “Step 1” request. Currently I am not getting any data, just making sure I can call the “Sstep 1” request from the post-response script.

When I call the webhook, this is what is happening:

I think somehow the monitor got disconnected from the webhook and it takes so long to receive the payload that apparently it throws a timeout.


And after that it tries to execute the create webhook request which should not be because I set another request to follow.

After this failure. I decede to go back and use setNextRequest to null in the “echo the payload” request, as it was initially. I removed the monitor. And I run the webhook requests again. I created the webhook, it returns ok, but no monitor was created. I call the webhook and it returns ok, but no monitor is visible in the UI. I closed and reopened the app (using mac) and there were the monitors. So I tried again. this time the monitor was created and visible.

When running the “Call Webhook” request it shows again as the image above, where apparently the webhook is waiting for the payload. and apparently it throws again a timeout.

I have another fork of the same collection, and it works, and the code is exactly the same.

What is the thing I am doing that messes everything? Is it possible to use this webhook thing to run collections that also receive data through webhooks?

I also have this question in stackoverflow, if you want to look there as well. webhooks - Postman - TypeError: Cannot read properties of undefined (reading ‘setNextRequest’) - Stack Overflow

Hey @rickersilva :wave:

Welcome to the Postman Community! :postman:

Just doing a quick glance over your code snippets - You have pm.execute.setNextRequest() which isn’t quite right.

It should be:


Also for the Webhook pre-request code, using this would remove the pm.globals warning you’re seeing in the console:

let incomingPayload = JSON.parse(pm.globals.get("previousRequest")).data
pm.collectionVariables.set("newPayload", incomingPayload.message)

Thank you @danny-dainton. I solved those warnings. However, the “message” attribute you use, always throws me “undefined”. I leave it without it, and it seem to be working.

So right now the webhook works, when using:


But If I change that to redirect it to “Step 1” request:

pm.execution.setNextRequest("Step 1: Initialise");

it stops working, just like the image in the post, waiting for way long until time out.

Once it finishes, this is what I got.

It indeed went to Step 1 request. The two logs in lines 8 and 10, are console.logs that I have in the scripts. I don’t know why the timeout. I have the VPN and api keys to that endpoint correct. I’ll try once more.

it is stucked again. I run “step 1” request prior to run it again so I am sure it is working, but it times out if it is run after the webhook.

Could it be some issues with the authorization. That API uses another key that is set as API Key in the folder containing that request.