Failed: Verify Status code is 200

Code that I have in postman API works fine

pm.test(“Verify Status code is 200”, function () {
pm.response.to.have.status(200);
});

It throws 2 errors while the same script runs in a monitor
Failed: Verify Status code is 200
expected { Object (id, _details, …) } to have property ‘code’

Any help is appreciated

Hey @Chandana :wave: , Welcome to Postman Community!

I was unable to understand the full context, but from what I understood, looks like the place where things fail, the URL in questions is not reachable.

Do things work locally on your Postman app and fail on Monitor? Or is it the reverse?

Check the Postman console and provide a screenshot here, that would help people understand where and what is failing.

Console may be opened by clicking on the “Console” icon, located at the bottom left
Screen Shot 2020-12-03 at 5.17.49 PM

Alternatively, you may open the Console Window by navigating to View → View Postman Console from the Postman app (native app only)

Also check this, to find out how to troubleshoot common errors when sending requests fails: Troubleshooting requests | Postman Learning Center

Amit,

Thank you for the quick response. Things work fine in Postman app, Console doesn’t throw any errors, but they fail in Monitor. Console Log that can be viewed from Monitor throws the above error.

image

I updated the code and new error comes up that value is ‘undefined’ ( Again only in monitor)

pm.test(“Verify Status code is 200”, function () {
pm.expect(pm.response.code).to.eql(200);
});

image

Print value in console is
console.log(pm.response.code);

image

Hey @Chandana, thanks for sharing the screenshots that helps.

From this image, I understand that ptdinttest1 is a server running locally on your machine
image

localhost (127.0.0.1), as the name suggests, is local to your machine and not visible externally on the internet. And the reason why things work fine when running locally on the Postman app.

Postman Monitor will not be able to access your locally running server, and thus the failures that you see.

Can this be resolved if we have a plan with Static IP address?

@Chandana your server needs to be externally accessible over the Internet for Postman Monitor to be able to reach it.

You can limit access to just Postman monitors by selecting and allowing Monitor’s static IPs on your Firewall/LB, if you are on the Business/Enterprise plan.

1 Like