Can we set variables automatically when creating a new request in Postman?

Viewed 112

I have defined some variables. Now I would like them to be automatically present in a new request.

For example, I would like the variable Auth_Token to be automatically present in as a bearer token in Authorization when I create a new request, just like the url.

For illustration:

enter image description here

Is there a way to implement this? I haven't found anything yet.

2 Answers

You can Manage Environments to declare many Variables after set some variables you can select your related variables from the drop down at the top right of the post man window. and you can send your request to your selected server.

Different ways to do it

  1. Just duplicate that request by clicking it and press ctrl+D - RECOMMENDED (make sure you save the source request before doing it )

  2. Else provide authentication in collection level - RECOMMENED

  3. Set url from pre request script in collection level - NOT RECOMMENDED as it causes confusion in long run.

    pm.request.url ="{{url}}"

    pm.variables.set("url","https://www.google.com") console.log(pm.request)

Related