Newman Modifying --env-var Parameter

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.

I’m using Newman to run integration tests via Teamcity and a python script.

I’m using newman cli and --env-var parameters to pass in variables that I can’t store in github. Newman sends a request to my API with a different variable value than I passed in via env-var. I am assuming this has to do with the ‘$’ char. Everything between ‘$’ and ‘#’ is removed from the string. I’m at a loss as to how to correct it.

--env-var “password=12$123456?#12345”

Gets turned into: 12?#12345

The python script runs a newman cli command similar to this:

newman run integrationTests/API-Collection.postman_collection.json -e integrationTests/variables/devIntegration.postman_environment.json --delay-request 1000 -r teamcity,cli --env-var “username=someusername” --env-var “password=12$123456?#12345” --verbose --bail

Note the change in password below in the request sent by newman:

{
  "id": "f2b73f50-f136-47c8-aa13-fc65b7123456",
  "name": "Get MyAPI",
  "headers": {
      "accept": "application/json",
      "authorization": "Basic cantpastethishere",
      "user-agent": "PostmanRuntime/7.26.0",
      "cache-control": "no-cache",
      "host": "myhost.host.com",
      "accept-encoding": "gzip, deflate, br",
      "connection": "keep-alive",
      "content-type": "application/x-www-form-urlencoded",
      "content-length": 108
  },
  "method": "POST",
  "url": "https://myhost.host.com/my/route",
  "data": {
      "username": "someusername",
      "password": "12?#12345",
  }
}

Hey @jadams

From the command line, $ would allow you to use a system-level environment variable so it looks like it’s interpreting that value here.

What you could do is store that value as a system-level environment variable like this:

export PASSWORD='12$123456?#12345' 

Then use that with your Newman run command like this:

--env-var "password=$PASSWORD"

This will use that value in the Collection run.

I’m using the htmlextra reporter with the --reporter-htmlextra-showEnvironmentData flag to display what variable was used.

Thanks Danny, that got me going. Good catch and good eyes!