postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Reuse the same request inside several collections

Open KumG opened this issue 9 years ago • 199 comments

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.

KumG avatar Oct 29 '15 08:10 KumG

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.

abhijitkane avatar Oct 29 '15 09:10 abhijitkane

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.

kurtfm avatar Nov 12 '15 20:11 kurtfm

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..

stephenliberty avatar Nov 30 '15 21:11 stephenliberty

+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!

andy-cam avatar Feb 15 '16 12:02 andy-cam

+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?

GabbyChangSH avatar Apr 13 '16 05:04 GabbyChangSH

+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.

ebelanger avatar Aug 31 '16 15:08 ebelanger

+1

rapidroamer avatar Sep 15 '16 00:09 rapidroamer

+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.

JohnArrowwood avatar Sep 27 '16 19:09 JohnArrowwood

  • 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!

satbirbains avatar Oct 29 '16 12:10 satbirbains

+1

gianisegatto avatar Nov 28 '16 13:11 gianisegatto

+1

ohitsdaniel avatar Dec 13 '16 14:12 ohitsdaniel

+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.

ahilsend avatar Jan 03 '17 13:01 ahilsend

+1

sd-bnguyen avatar Jan 25 '17 00:01 sd-bnguyen

+1

steher avatar Jan 30 '17 11:01 steher

+1

sowjanyaqsg avatar Feb 06 '17 11:02 sowjanyaqsg

+1

Please let us know when such ability will be available.

Workom2016 avatar Feb 16 '17 11:02 Workom2016

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 :)

sdnts avatar Feb 16 '17 11:02 sdnts

+1

juniorplenty avatar Mar 08 '17 19:03 juniorplenty

+1

jlundy2 avatar Mar 13 '17 17:03 jlundy2

+1

LolaYan avatar Mar 22 '17 03:03 LolaYan

+1

brian-prince avatar Mar 27 '17 18:03 brian-prince

+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

arpadffy avatar Jun 09 '17 13:06 arpadffy

+1

brianpburns avatar Aug 03 '17 21:08 brianpburns

+1

MBurchard avatar Aug 04 '17 11:08 MBurchard

+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!

RichardForshaw avatar Sep 13 '17 02:09 RichardForshaw

+1

toolmania1 avatar Oct 26 '17 12:10 toolmania1

+1 I would like to do this as well. If changes are required we need to update multiple places.

Thanks, Cody

codynolf-legacy avatar Nov 02 '17 17:11 codynolf-legacy

scalability and maintenance--hello? it just makes sense to be able to re-use request and test items, especially when they are parameterized.

testmonger avatar Nov 16 '17 11:11 testmonger

+1

rsaa avatar Nov 21 '17 15:11 rsaa