You can do this by adding
var rnd = Math.floor((Math.random() * 10000) + 1); postman.setEnvironmentVariable("firstname", "fname"+rnd); postman.setEnvironmentVariable("lastname", "lname"+rnd);
in the Script pre-query section.
And then adding
{ "firstName":"{{firstname}}", "middleName":"mani", "lastName":"{{lastname}}" }
in body.
I tried this in both Postman and Newman, and works great on creating a random first and last name.
Aejey source share