Postman request

i am having few GET requests in my collection,repeating at many instances… For example, A GET request is used for a job creation validation, same call is used after job edit validation, and then job deletion.

I want to eliminate the repetitive GET Calls by keeping only one call than calling after it wherever required…

Is is possible in postman?

Need to call request by keeping one request wherever required

Not easily.

Postman are working on features in relation to reusability of scripts and requests but I don’t know the fine details on how it will work or when those features are going to land.

Currently the only way to control the flow of tests is using setNextRequest, which just tells the application which request will run next, after the current request and all of the code in the pre-request scripts and tests tab (at whatever level) have completed.

What it won’t do is run that request and then pass control back to the next request in a folder.

An alternative, is to script a function using sendRequest() that mimics that GET request (instead of a full on GUI request) and run it from a pre-request script (so its gets evaluated before request is run). You should then be able to call that function in the tests tab for the relevant requests.

I would recommend that that function stores any important keys in the response to local variables (using pm.variables.set), so each of the requests that call this function can have relevant instead of generic tests cases. For example, include the job number, so that you can test that the job number sent in the request is the same as what is returned in the response.

1 Like

@michaelderekjones thanks for your reply on this

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.