I would like to test my GET request with 4 iterations using data stored as 4 objects in external JSON file. As its JSON file I have stored it in key value pair as below:
Values are getting picked/stored as “AAA”, “BBB” “CCCC”,“DDD” in environment variable and not as AAA simply. Because of double quotes those are getting assigned as %22AAA%22 after encoded by Postman in GET URL. This is causing me to get response code as 404 and not 200. What is the right way to test GET API with data variation using external JSON file?
You need to ensure that if you have made changes to the request in the builder, that you save the changes in the request tab before running the collection.
I mentioned 4 iteration but in example given only 2 my bad.
Yes I have 4 objects in my JSON and i am going to add more data to these objects to use data variation for those requests. In short i wish to use 1 single file which will contain data sets for multiple request from collection.
I am using pm.environment.set(“ABC”, JSON.stringify(data.ABC)); to notify which data need to be picked from file as file will hold data for other requests too.
Can you suggest me best way to test API collection with multiple iterations(Each iteration will hold different data) for all requests in the collection having data stored in single external JSON file.
So for e.g. I have Collection as CCC which includes Request (POST),Request 2 (GET),Request 3(GET) and data for these requests is need to provide from external JSON
I mentioned removing that script because if you only have {{ABC}} in the request, the value would have been resolve from the script without the need to add the pre-request setting.
In terms of good practices - @vdespa’s tutorials are always a good start: