Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to trigger another request in collection from pre-request script #697

Closed
prathiraj opened this issue Aug 22, 2014 · 172 comments
Closed

Comments

@prathiraj
Copy link

[Feature request]

Add ability to trigger another request in collection from pre-request script

@tmcdonnell87
Copy link

+1 - this alone would probably get my team to upgrade to using pre-request scripts. Very common for us with one of our token generation schemes. OK if only in the packaged app and not Chrome.

@abhijitkane
Copy link
Member

@prathiraj @tmcdonnell87 - trying to understand the use-case here -

In the pre-request script for request r1, you check if a condition is true. If true, you fire request r2, set environment variables from the response of r2, and use those variables in r1.

Is that correct?

@tmcdonnell87
Copy link

Two cases:

1 - Exactly what you said, though to elaborate, it may be a data-based condition. Only some values would require the pre-request.
2 - Usability for auth with limited-use tokens. Right now you can set the response to a previous call as the auth token, but it requires actually sending the request. If you have single-use tokens, you need to back up and get a token each time. (Also each token is good for only one API, which clutters collections.) Getting the token in the pre-request script would save a ton of time, especially for the QA team.

Thanks!

@prathiraj
Copy link
Author

+1 to what @tmcdonnell87 said.

@nonnenmacher
Copy link

+1 also
and as a duped feature request of having more external lib available, a way to inject crypto.js like lib, will be immensely valuable.

For now it oblige to make specific collections, just to feed environments variables by calling special API calls, to compute this kind of 'auth / security / crypto' needs for token, nonce....

@ghost
Copy link

ghost commented Feb 7, 2015

+1 this would be immensely useful.

@MarcosRava
Copy link

+1

3 similar comments
@LeoLeal
Copy link

LeoLeal commented Mar 16, 2015

+1

@gadelkareem
Copy link

+1

@luisgmoreno
Copy link

+1

@42thcoder
Copy link

+1

It will change the way we test our API

@ponvino
Copy link

ponvino commented Jul 29, 2015

+1

2 similar comments
@dominiksipowicz
Copy link

+1

@reallistic
Copy link

+1

@sp72
Copy link

sp72 commented Sep 14, 2015

+1, thanks.

@dineshk-qa
Copy link

+1, definitely need this feature

@MarcosRava
Copy link

You can use test script to populate enviroments after request

@tmcdonnell87
Copy link

Yes... but that's a very clunky process , especially if you have multiple requests in the chain or conditional logic.

@nonnenmacher
Copy link

I agree, especially if you look at the original request, that outline that
chaining scripts,
could be to populate environment data for your current/real test.

This feature is the logical next step, for progressively build a complete
set of environment variables
that could be expanded during the real value of a script/test.

Take for example a complex, crypto setup where during a login phase, some
dynamic/shared secret
are built-up, to obtain at each end such common understanding/secrecy and
feed back a token
on each requests of a postman test suite.

On Wed, Sep 23, 2015 at 4:33 PM, Terry notifications@github.com wrote:

Yes... but that's a very clunky process , especially if you have multiple
requests in the chain or conditional logic.


Reply to this email directly or view it on GitHub
#697 (comment)
.

@Evanlec
Copy link

Evanlec commented Dec 23, 2015

+1

@loretorafa
Copy link

+2

@srbangre
Copy link

+1

@a85 a85 added transfer and removed transfer labels Jan 27, 2016
@kyle-felizz
Copy link

+1

@mobiletoly
Copy link

+1

1 similar comment
@bencami22
Copy link

+1

@stramel
Copy link

stramel commented Jun 26, 2018

@joaovpmamede @sh3raawii and anyone else like myself who wanted this issue to allow sending of collection requests, please go over to this issue and give it a 👍

GO HERE: #4193

@ghost
Copy link

ghost commented Jul 4, 2018

+1

4 similar comments
@jayarjo
Copy link

jayarjo commented Jul 12, 2018

+1

@AnkitKabra20
Copy link

+1

@lartie
Copy link

lartie commented Jul 24, 2018

+1

@zankhanarana9
Copy link

+1

@stramel
Copy link

stramel commented Aug 14, 2018

@shamasis @abhijitkane @czardoz Do you mind locking this thread so it doesn't continue to get +1s?

@magusd
Copy link

magusd commented Aug 14, 2018

+1

@jakeNiemiec
Copy link

Do you mind locking this thread so it doesn't continue to get +1s?

➕💯

@raylapse
Copy link

  • 1

@raylapse
Copy link

+2

@ghost
Copy link

ghost commented Nov 22, 2018

+1

@Flangvik
Copy link

+2

@vosamoilenko
Copy link

+1

1 similar comment
@attilahogyai
Copy link

+1

@parul3389
Copy link

It is may be a very late reply, but I just found something very simple, which might be helpful.
In tests area of authorization request, we can assign this request to some varibale.
pm.globals.set('authorization_request', pm.request);

And then same variable can be used into other request pre-requsite script.
pm.sendRequest(pm.globals.get('authorization_request'), function (err, response) {
pm.globals.set('token', response.json().access_token);
});

@RichFoo
Copy link

RichFoo commented Mar 7, 2019

It is may be a very late reply, but I just found something very simple, which might be helpful.
In tests area of authorization request, we can assign this request to some varibale.
pm.globals.set('authorization_request', pm.request);

And then same variable can be used into other request pre-requsite script.
pm.sendRequest(pm.globals.get('authorization_request'), function (err, response) {
pm.globals.set('token', response.json().access_token);
});

This works, but the captured request is captured with all of it's variables resolved (unsurprisingly). So, if you switch environments, you'll need to re-run the authorization request to re-generate the captured request with the correct parameters. It's definitely a start, though!

@spencerrichardhenry
Copy link

Why is this issue marked as close? I see no resolution

@Dmitresky
Copy link

any updates?

@fergardi
Copy link

What I ended up using was the PreRequest scripts in a the collection itself, so that every single request inside that collection executes that script and gets the API token refresh, for example.

@bencami22
Copy link

bencami22 commented Feb 17, 2020 via email

@albertlieyingadrian
Copy link

+1

1 similar comment
@mvdcorput
Copy link

+1

@FullofQuarks
Copy link

Still don't see a resolution in this thread that was opened 6 years ago...instead I see multiple issues revolving around the same feature request, and comments like "Do you mind locking this thread so it doesn't continue to get +1s". So instead of addressing the issue (I continue to see activity on this issue, #4193 and #4845), you'd rather lock it so no further comments can come out of it.

Either close all the issues as "wont-fix" or actually consolidate them all into one issue (as requested last year in #882). Or maybe we can discuss the issue. You know, like what GitHub issues are for.

@jdelpierre
Copy link

+1

@MukeshMM
Copy link

MukeshMM commented May 9, 2020

+1000000

@arlemi
Copy link
Collaborator

arlemi commented May 11, 2020

Hey 👋 I've gathered all feedback from here and other issues into a single one, please add a 👍 reaction to the first post there if you'd also want that feature.

➡️ #4193 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Runner
Suggestions
Sandbox/Runtime
Suggestions
Development

No branches or pull requests