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’ve been using newman to do some automation, but I’m now beginning to hit a wall when I use it with node.js. Here’s the node.js code
const newman = require('newman');
newman.run({
collection: require('./my.json'),
iterationData: require('./my.csv'),
iterations: 5,
reporters: 'cli'
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
// Log the request body
console.log(args.request.body.raw);
}
}).on('request', function (error, args) {
if (error) {
console.error(error);
}
else {
// Log the response body
console.log(args.response.stream.toString());
}
});
When I run this code, it cannot process the URL which includes a variable with double curly braces, i.e. http://myserver/{{variable}}
When I run node.js with a the above javascript. I get
ReferenceError: variable is not defined
it’s not a parameter, so it’s not a key-value pair.
Not really sure what’s happening without more details but iterations should be iterationCount. As you’re using a data file, that’s not really needed as that should control that value.
Are you able to share the full error message you see? What is variable and is that contained in your collection somewhere?
The variable is the last part of the URL in the curly braces above. It’s not a key value pair. As far as the full error:
/Users/pr85/Downloads/my.csv:1
variable
^
ReferenceError: variable is not defined
at Object. (/Users/pr85/Downloads/my.csv:1:2)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (/Users/pr85/Downloads/test.js:5:20)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
When I run newman with -d option, same file, it works as expected and substitutes the variable correctly.