TypeError: pm.setNextRequest is not a function

This is my only line in my test script, it is giving me TypeError: pm.setNextRequest is not a function … Why is this happening? v6.7.2

pm.setNextRequest('MyRequest');

The pm.* api doesn’t have that feature yet. I would try postman.setNextRequest() instead.

1 Like

Thanks. Ah. I was looking at harryi3t here - https://github.com/postmanlabs/postman-app-support/issues/4193 , where he uses pm.

Changed it to postman and now I’m not getting an error but it’s not working either. Hmm.

I get the message logged to console here but the next request does not fire.

if (pm.globals.get("bearerToken")===null || pm.globals.get("bearerToken")==='') 
{
    console.log('bearerToken is null or empty. fetching....');
    postman.setNextRequest('GetToken');
    pm.variables.set('goto', 'MyRequest');
}

Oops I was running it by itself not the folder/collection (collection runner), working now. Thanks again.

1 Like

Hello, I have a question regarding this. For setting a monitor in Postman, I read that only pm.* operations works on the sandbox (the monitor) while postman.* operations does not work on the sandbox. is this true?, if true, is there a way to loop the same request with different parameters on the monitor without using postmant.setNextRequest.

Thanks.

Hi there @victorregoz - you can use postman.setNextRequest() in a monitor.

If you read that somewhere on the Postman website, can you let us know where, so that we can clarify?

1 Like