Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test for multiple acceptable status codes in Postman? [closed]

I have an endpoint that can return status code 200 or 400 depending the time of day. How would I go about creating a test that can check for either of them?

like image 308
matias90 Avatar asked Mar 16 '18 04:03

matias90


1 Answers

pm.test('Check status code', () => {
    pm.expect(pm.response.code).to.be.oneOf([200, 400])
})

That’s a quick example of a test that would check to see if the status code was either 200 or 400.

like image 78
Danny Dainton Avatar answered Sep 22 '22 11:09

Danny Dainton