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.
In my scenario I need to use Node as the operating environment and pass variables out of Newman and used from within the .js that will be executing the script to start the collection:
newman.run({
collection: require('./somename.postman_collection.json'),
reporters: ['cli', 'html']
delay: ['200']
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
fs.writeFile(`request.txt`, args.request.body.raw, function (error) {
if (error) {
console.error(error);
}
});
}
}).on('request', function (error, args) {
if (error) {
console.error(error);
}
else {
fs.writeFile(`response${getDateString()}.txt`, args.response.stream, function (error) {
if (error) {
console.error(error);
}
});
}
});
This .js will also be processing some data-files (which are the names of the variables that would be passed out of Newman) then use the new data-file (using appendFile to make multiple files one larger file) as input for the collection to be run. The alternative would be to use JS to make the HTTP:POST request and parse the JSON outside of Newman; however, this solution has eluded me as well. Any help would be GREATLY appreciated.