I am running a PATCH and a POST request through a collection runner. I’m using a csv and passing a few variables to the endpoint and body. The PATCH updates a ticket status and the POST adds a comment to the ticket. It works, but there are 2 things I’m trying to accomplish to make it better that I’m struggling with:
- If the PATCH fails (e.g. 400 error for a bad value in the csv), I do not want the POST to add the comment, and I want to skip to the next PATCH/next iteration.
- For the POST, I’m passing a ‘Comments’ string, which is sometimes null. If it’s null, I’d like the POST to be skipped, because otherwise a comment is inserted into the application I’m integrating with, showing as null, but with a timestamp, entered by, etc., which is unnecessary and confusing.
I feel the postman.setNextRequest would be used, but I’m struggling to get it to work in my tests section / pre-request script.