I am using a REST API with a POST request. I have created a CSV file to load in various inputs and using the Collection Runner to submit my requests and run the associated JS Tests iteratively. I am trying to figure out how I can also have an entry in each row of the CSV to reference for my JS Test in order to make the JS dynamic. Iāve searched the POSTMAN documentation and forums, as well as Google and Stackoverflow, but havenāt found anything that works. Here is a basic example of what Iām trying to accomplish.
Letās say I have a basic adding API. Here is my Request:
{
āNumbersā: {
āValue_1ā: {{val1}},
āValue_2ā: {{val2}},
}
}
The CSV file is as follows.
val1,val2,sum
1,1,2
2,2,4
3,3,6
For this example, lets assume that the API returns a response that includes the sum of val1 and val2; something like this:
{
āNumbersā: {{sum}},
}
I am able to load val1 and val2 into my request and iterate through the request for each row, but I am having trouble incorporating the sum values (from the same CSV) into the JS Test.
I am trying to do something like the test below where I can reference the sum value from my spreadsheet, but Postman doesnāt like my syntax.
pm.test(āAdding machineā, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.Numbers === {{sum}});
});
Does anyone have any suggestions? Is this even possible to do?