Hello, I’m searching a way to repeat an already defined request in a collection when I use another request in order to not duplicate the request.
nextRequest feature doesn’t work for me in this case since this common request will be used in several request in the collection. Also not all of them will use it, so define it in folder level is not a solution for me.
The most important thing for me is the Test part since there I store data generated in the response of the request to be used in later requests, but that’s not the case. I don’t mind if the Pre-request part can’t be executed along with the repeated request.
I’m not sure what is the exact issue but from what I understood is that I think you need to send a specific request inside another based on some condition.
If my understanding of your problem is correct then you can use this solution. I have taken a sample url.
Hello @jchaugule. Thanks for your reply. Maybe your solution is a bit convoluted. My question is to try to trigger an already defined request in a collection (including its Pre-request script and Test scripts) when it’s launched another request in the same collection.
To clarify, my case is something like this:
I have a test case that first launches Request A in a collection launched normally with a runner or Newman that creates an object. In its test part it’s stored the id of the object and other data.
The next requests work with the previous object created in Request A and finally the object is removed once the test case is finished.
Later in the same collection I want to launch another test case. To do it I need to launch Request B that needs object that is created in Request A. Instead of duplicate the request (including all its Pre-request scripts and Test scripts parts) I would like to ‘invoke’ Request A (including its Pre-request and Test scripts). This generates a new object so I need to store its data as before (id from Mongo database and so on).
Then I continue with other requests and finishes the test case.
The bold part is what I’m searching to achieve in order to avoid duplication of code and maintenance of all of this.