Hi @hannah.neil @praveendvd @bpricilla
i have a small query and i am looking for your suggestions on this .
Problem
i am working on the post method and as a part of it i have to send the body.Body looks like this
{
"id": int,
"maxWeight": int,
"minWeight": int,
"disabled": boolean
}
i am trying to acheive something like this
i kept the below code in the pre-request at folder level
var weightCategory = ["1-0-50","2-51-100","3-101-150","4-150-200"];
pm.environment.set('weightCategory', weightCategory);
pm.environment.set("weight", weightCategory[Math.floor(Math.random() * weightCategory.length)]);
Now for every run i am getting the one out of the listed weightcategory, fine til this point.
What i want to acheive is
Suppose the weightcategory i got is โ1-0-50โ , then i want to see these values in request as below
{
"id": 1,
"maxWeight": 50,
"minWeight": 1,
"disabled": randomboolean
}
i kept the below code in pre-request tab at request level
pm.environment.set("data",pm.environment.get("weight").split("-"))
console.log(pm.environment.get(data[0]));
But in console i am getting undefined when i am expected it to log โ1โ
Can Someone help me on how i can acheive this
HappyTesting.