The errors seems to say that the variable is undefined, however, the requests run perfectly when I send them in postman.
Here is the “Tests” script:
postman.setEnvironmentVariable(“data”, pm.response.headers.get(“Location”));
var internal = pm.environment.get(“data”).substring(109);
postman.setEnvironmentVariable(“packlineid”, internal);
Additional note: I am exporting the collection as JSON.
OK… Thanks for the reference. I went ant Exported the environment, and then tried running the collection, however, I am now getting a not authorized error:
OK… I have now gone and manually entered the values of the environment variables (they exported blanks) in the Environment JSON file, and successfully re-ran the collection with Newman. Thank you for the help.
There is only one question left now: Why did the environment export not include the environment variables values?
Its because of “initial” vs “current” values.
Initial values can be exported and shared with your team.
However its the current values that are used when sending a request and these are not exported (or synced to the Postman cloud).
If the current value is left empty, then it will automatically use the initial value (if its set).
A lot of the times, the environment variables are used for information that should not be stored in your code repository (or the Postman cloud).
Therefore you store these values elsewhere (for example, we use Azure Key Vault). Retrieve them as apart of your pipeline and then send them as individual values through the Newman command line.
If its not confidential information (like environment host names), then you can store the info in the initial value.