I have a webhook monitor created following the instructions in this video. Apparently, it works ok.
Given that, I want to use it to catch the payload sent by a webhook and then trigger another request in the same collection using some of that data. I decided to make a simple try out. I run the “Call webhook” request which only sends a very simple json body to the url webhook created with the request in the “Create webhook” folder. That webhook returns the payload and it is caught by a monitor that runs the “Echo the payload” request. May be my concepts are not perfect, but that is how I understand.
Calling the Step 1 request alone, works perfect, it creates something in the system and I get an Id. That is the result Iant at this moment. I want the “Echo the payload” request to hand over to “Step 1”. I used 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, but it also behaves the same using the request name.
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:
You can see it is reaching the monitor and running the pre request script and the test script (they changed that recently and is the now called post-response script). It is running the “about to run Step 1” log, but then throws an error I cannot figure out.
Then, even weirder, it is running the create webhook request, and then the call webhook again. Remember I used
pm.execute.setNextRequest("2311b468-9c9e-4a59-ad2a-e37d631c107c");
to control the test flow. It is taking so long to run because it is, apparently, entering an infinite loop.
I don´t know what TypeError: Cannot read properties of undefined (reading 'setNextRequest')
means and how to solve it.
I expect it to handover to step 1 request.
Thank you,