Postman CLI pass in Global Variables

Hi all,

Been using the Postman CLI tool for a couple weeks, I can see that environments can be passed into the command line using a UID, but global variables are done using either a file path or adding them directly to the command.

Have I understood this correctly and is it possible to pass a UID to use the global variables on a collection run.

Thanks

1 Like

I am trying to figure out the same thing right now. If I can figure it out, I’ll share here.

Hi all.

Global variables are shared across a workspace and hence only available within the context of that workspace. To use a variable on the CLI, you have to use an environment variable like you suggested or store this variable in a different file.

The Postman API has recently released a new endpoint to read and update the Global Variables in a Workspace.

For usage on the Postman CLI, you could use that URL in the command to access the globals:

postman collection run {{collection_uuid}} -g "https://api.getpostman.com/workspaces/{{workspace_id}}/global-variables?apikey={{postman_api_key}}"

The scope of the variable used should be the correct one for the context. Is a global scoped variable, the most appropriate for your context?

1 Like