Setting Collection variables from scripts

Using pm.collectionVariables.get() and pm.collectionVariables.set()methods in pre-request script or tests to access the collection variables, as described in the product documetation gives a “There was an error in evaluating the Pre-request Script: TypeError: Cannot read property ‘set’ of undefined” error. What is the right way to set the collection variables from a script.

Hey @conigbinde Welcome to the community :wave:

pm.collectionVariables object was added in Postman version 7.9.0 - Do make sure you are on the latest Postman version to utilize this: https://www.getpostman.com/downloads/

If you are getting this error on version 7.9.0 or later - let me know which version you are using.

1 Like