Postman scripts : "pm is not defined"

Viewed 43798

I try to write a Pre-request script in Postman. I want to to make a request so I try to use pm.sendRequest. For example :

pm.sendRequest('http://example.com', function (err, res) {
    //...
});

But I get this error :

There was an error in evaluating the Pre-request Script: pm is not defined

I'm on Windows 10. I just updated the extension.

How do I access pm?

4 Answers

For extension version, you can use following pattern:

tests["Status code is 200"] = responseCode.code === 200;

Replace pm with postman, it should work fine.

Related