Looping through array variable

Hey sachin,

Welcome to posman community.
The issue is when you store something in environment or from test script it is stored as a string that’s the reason you get the length as 39.

There are 2 ways to handle this

  1. Use the split function to store it in a array like this
let Users = pm.environment.get(‘UserId’);
let UsersArr = Users.split(",");

After this you can access values under UsersArr as UsersArr[0] & the length will be 3.

  1. If you are extracting users from a API call, either chain it to next request or save each value individually rather than a array.

Let me know if this works for you.
Regards,
Skandh