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.
Hi guys. I tried different solutions but nothing seems to work. I’m a beginner in Postman/Newman collections. My end goal is to have a working solution with Newman being integrated with Jenkins.
So, I have the collection and a “Pre-request Script” where I basically handle random Strings/Numbers to be assigned to a Global Variable, something like this:
const dateNow = new Date();
pm.globals.set("currentDate", dateNow.toISOString());
pm.globals.set("randomNumber", _.random(1,9999));
function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {
if (!minValue) {
minValue = 8;
maxValue = 8;
}
if (!maxValue) {
maxValue = minValue;
}
let length = _.random(minValue, maxValue),
randomString = "";
for (let i = 0; i < length; i++)
randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));
return randomString;
}
pm.globals.set("randomPincode", randomString());
As you can see in the following screenshot the variables are correctly defined:
Then, in the request, I just call that variable and the value will be stored correctly in the Global Variable.
{
"momentOfOrigin": "{{currentDate}}",
"eventId": {{randomNumber}}
}
So, running directly from the Postman works fine, but the issue occurs when running it from Newman CLI.
I already exported those global variables as JSON and when running from the command line I’m using: newman run Collection.json -g global_variables.json
As a result, all the requests are having the status 400 Bad Request. I guess something goes wrong in defining the variables but I don’t know what.









