I am working with the collection in this video https://youtu.be/wdLvXKkXhLk?si=qqA3w_Es9x6K5OCA. 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
//postman.setNextRequest(null)
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
console.log("hello from the Test Script!", pm.collectionVariables.get("webhookData"))
console.log("about to run Step 1.");
pm.execute.setNextRequest("2311b468-9c9e-4a59-ad2a-e37d631c107c");
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