pm.sendRequest not working in post request Test

I created a method in collection level prerequest script as follows :

utils = {

  testPMReq : function() {
       console.log("I am here");
        pm.sendRequest("", function (err, response) {

and then used this method in a post request test as follows :


It prints out: “I am here” but it doesnt execute the pm.sendRequest call.

When I call utils.testPMReq(); in collection level pre-prequest script right after method creation, it executes the send request call.

Can someone please help why sendRequest is not working when I execute the method from post request script and how I can make it work?

1 Like