Test with multiple records

Hi, I’m trying to post several records with a loop. Below is what I have in the Body, Pre-Request Script, and Tests Sections. I tried to run it just by clicking “Send” and it created the first record but would not repost with record 2 and record 3. This is just a basic test that I want to expand upon if successful. Thank you in advance. I am setting the Authorization Token in the Header as well as the content-type (application/json)


"email": "{{email}}",
"first_name": "{{fname}}",
"last_name": "{{lname}}"


var emails = pm.environment.get(“emails”);
var fnames = pm.environment.get(“fnames”);
var lnames = pm.environment.get(“lnames”);

if (!emails) {
var email = [“test1@testco.com”, “test2@testco.com”, “test3@testco.com”]
var fname = [“first1”, “first2”, “first3”]
var lname = [“last1”, “last2”, “last3”]

var currentEmail = email.shift();
pm.environment.set(“email”, currentEmail);
pm.environment.set(“emails”, emails);

var currentFname = fname.shift();
pm.environment.set(“fname”, currentFname);
pm.environment.set(“fnames”, fnames);

var currentLname = lname.shift();
pm.environment.set(“lname”, currentLname);
pm.environment.set(“lnames”, lnames);


var emails = pm.environment.get(“emails”);

if (emails && emails.length >0) {
} else {

Be sure that when you access the arrays in the environment that you’re using JSON.stringify() when you store them, and use JSON.parse() when you retrieve them. It might be failing silently on the second run because it’s not getting a structure of data the way you think.