Here is my requirement: Appreciate any pointers:
- Make a post request - Done
- Save the portion of the JSON response into env variable (var name = envbody) - Done
- Read the env variable (envbody) to get JSON schema with values - Done
- Read csv file has 100 rows with query and locale - Done
- envbody environment variable has Json object stringified - Done
- envbody has json with one of attribute name called query.
Replace query attribute value of envbody with csv iteration data query value - Repeat till end of csv file
I have done 1-5. How do I manipulate / insert value into envbody variable
Here is the code snippet
var resultObject = JSON.parse(responseBody);
var searchBody = resultObject.searchPostBody;
var searchBodyStr= JSON.stringify(searchBody);
postman.setEnvironmentVariable("searchPostBody", searchBodyStr);
Reading csv file - No issues
Need to replace one of the attribute value in searchPostBody env variable using csv iteration data
For example, in this case, searchPostBody
has a Json object with one of the attribute names is query (q)
.
I need to replace the value of “q” with the value which is read from the csv file.
{
"expe": "xxx",
"q": "",
"limit": 10,
"locale": "en_US",
"timeout": 10000
}
Thanks, Raje