0

I am new to postman and I have some 200 services to automate. Now for every service I need to save some values and retrive in other services. Now can I do it by saving and retriving from environment variables.

Is there any other option other than saving in environment variable ? Like at collection level itself ? Also the environment list looks big if I start to save the values in them ?

Looking for different options ?

1 Answers1

4

You can define collection variables

Click ellipsis (...) next to the collection name, and select “Edit” to open the EDIT COLLECTION modal. Select the Variables tab to add and edit collection variables

enter image description here

Using code:

pm.collectionVariables.set("variable_key", "variable_value");
pm.collectionVariables.get("variable_key");
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
  • so how can I set and get the values ? Same way i set the environment variables ? Like I want to set some values and then use it within the collection. How can I say to save the values at collection level ? – dineshbalajibingo Nov 08 '19 at 12:59
  • I am not able to set the values to the collection variables - "Cannot read property 'get' of undefined" - pm.collectionVariables.get("variable_key"); – dineshbalajibingo Nov 08 '19 at 13:21
  • @dineshbalajibingo: Working in my machine : https://i.stack.imgur.com/gHc6r.gif not sure how come this issue. What is your Postman version? – Divyang Desai Nov 08 '19 at 13:32
  • 1
    My postman version is older and need an update. Thansk for the gif and explanation. That was really helpful. Thank you so much @Div – dineshbalajibingo Nov 08 '19 at 13:53