postman-app-support
postman-app-support copied to clipboard
Reuse the same request inside several collections
Is there a way to reuse the same request in several collections ? I didn't find how.
For example, I need to call a login method before any other method call, and I want my collections of tests to be independent. If I duplicate the login request, I will have to edit all the requests if I need to change something.
This is currently not supported. You can use environment variables (https://www.getpostman.com/docs/environments) so that you don't have to change each login request. Just changing the environment variables will do.
I think it would be nice to have something like a linked test. Right now if I need to chain a certain test before other tests in multiple places (say to get a unique id before updating or deleting) I have to duplicate the test. Then if I realize I have an issue in the pre or post logic I need to go through and clean each one individually.
I'm +1'ing - ran into this problem as well. If an endpoint changes, or a step needs to be added (like pulling more details out of a login response), it needs to be done on every request. Not exactly great..
+1 for this, our use case requires several steps along a user journey before certain calls will function as expected, and we don't want to litter collections with duplicate, unlinked requests. Global (or superclass-like) tests that can be referenced in collections rather than duplicated would be very powerful!
+1 And does there any other workaround to solve these problem? @abhijitkane, how to add one request in the environment variable? Can you give one example?
+1 - this is especially true when collections are used for test automation with newman. I can understand that it may not be a priority from the postman UI, but the value of reusable parts in tests has been proven times and times again.
+1
+1 I don't just want to re-use the URL. I need to re-use the whole request. The pre-request script. The request body, where appropriate. The request method. Everything. It might be nice to have custom post-tests. But if we can't do that, I can live without it.
- 1
If each collection is treated as an independent flow of requests of which all require their own login, then setting an environment variable is not suitable. Currently the only option is to duplicate the login request in every collection, the more requests that need to be shared the worse the situation will become.
With newman we can automate the process of running collections and as such also run them concurrently making this a must have feature for test automation and make this a much more powerful tool!
+1
+1
+1
Maybe something like a set of request definitions (probably parametrized through env).
And a "test definition" could take several such definitions, and a list in which sequence to execute those. This way requests could be shared across test runs, and one test run could run the same request twice if needed.
+1
+1
+1
+1
Please let us know when such ability will be available.
Guys, we're working on collection level scripts, which I believe should solve all your issues. Will let you know here when we make progress :)
+1
+1
+1
+1
+1
This is a highly desired feature. It would allow writing complex test sequences based on a common API call library. Hope this feature will come soon.
+1
+1
+1
+1
As a suggestion, perhaps providing a synchronous way to execute another script by name in a pre-request script, such as postman.executeRequest(RequestName)
? (Or even better a collection name).
This would allow common setup to take place for collections.
Thanks for the great tool so far!
+1
+1 I would like to do this as well. If changes are required we need to update multiple places.
Thanks, Cody
scalability and maintenance--hello? it just makes sense to be able to re-use request and test items, especially when they are parameterized.
+1