In Postman you can define multiple response examples.
200 > success
404 > not found
In the postman collection, the examples are added but I cannot execute the request in Postman to return a 404.
I want to be able to run a request 2 times:
happy path: run the request and test if the path returns a 200
unhappy path: run the same request, but for example use a blank request parameter and test for a 404
Is there a way to do this natively in Postman?
Or is the only option to duplicate the request and manually modify the request to make the parameter blanc and test for a 404?
Hi @thim! I’m not sure if I’m fully understanding your question, but here’s a method that may be helpful for you:
removeQueryParams allows you to programmatically remove a query param from a search. You can add in some conditional logic in your Pre-request script to determine whether or not to include a query parameter.
Hi @thim, I just clicked send twice. Since you said single request for validating two response codes. Based on your need you can tweak it It’s a rough idea based on my logic
How are you running the remaining requests? And what’s the business usage for validating the same request for two different response codes?
@thim if you want to run requests in a collection in a specific order (or in your case, rerun the same request based on some status code conditions), you can do so using the postman.setNextRequest() method. Here’s a helpful resource on building workflows.