Accessing global variables when running collection using Newman

Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

Hello!

I am using newman to run requests from a postman collection file. This file was created using the Postman export feature. Ex:

newman run “Tests.postman_collection.json”

I have created some global variables inside of Postman, and I call those in the GET request url. Ex:

https://{{instance}}.testing.devops.com/

This all works when I run from the Postman UI. But when I run from command line, it doesn’t replace “{{instance}}” with the global variable named “instance”. Is there another step I can take to make this work? Or, do I have to hard code the values in the exported collection file?

Thanks in advance!
dcarva

Hi, @dcarva! Welcome.

Globals can be passed as a command line parameter, either as a JSON file path/URL (via --globals) or individually (via --global-var). See here: https://github.com/postmanlabs/newman/#newman-run-collection-file-source-options.

Thank you! That works for me.

Hi, @dcarva,
can please share the step by step to run this, im facing same proble
i have more then 10 api and every api dependes on other api response.
its working when run using postman but not newman

First, export environment and global variables as JSON files
Then, you can use this command

newman run Automation.postman_collection.json --globals “” --environment “”