Hi . Can I know how to make postman ignore the response when it fail but let it run as usual if it is pass? I hope you guys can help me
Hi @technical-technologi! Welcome to the community
As I understand it, you want to run chained requests in a collection such that:
- It terminates if one request returns an error code (e.g 40X and 50X).
- It continues to the next request if the response status code is 200.
If this is what you want to achieve, you can include a script similar to the following example in Tests tab:
if (pm.response.code === 200) {
postman.setNextRequest('Your Next Request')
} else {
postman.setNextRequest(null)
}
Hope this helps! Please let me know if this is not exactly what you are after
@technical-technologi Welcome to the Community
So you are running the collections using Newman or Collection runner?
If using newman here are the list of newman commands.
Hi. What I meant is if the response has the object that I am testing for then it will run the test. But if the response do not have the object that is supposed to be then it will just skip run it and continue check the other responses. let me know if you want a better explaination
Thanks for clarification
In that case, maybe you can do something like this?
if (pm.response.json().SOMETHING) {
// do something
} else {
// do something else
}
Also, there is a JavaScript reference here that you might find useful