Hi all,
I have a json data file, and list of request as “Get a single booking”, “Get a bulk booking”… inside a folder “Get a single booking”.
- The request “Get a single booking” has URL: {{baseURL}}/booking/{{bookingId}}
- In folder “Get a single booking”, I configure Pre-request script:
let requestName = pm.iterationData.get(“requestName”);
postman.setNextRequest(requestName)
The purpose is each iteration will call a specific request_name, and assert the corresponding data
Let say:
-
iteration 1 sees the request name “Get a single booking” => call this request and ignore the others => assert the response data
-
iteration 2 sees the request name “Get a bulk booking” => call this request and ignore the others => assert the response data
But actually, The iteration variable is always 0, and calls to “Get a single booking”. How could we achieve that.
{
"requestName": "Get a single booking",
"bookingId": 1,
"expectResponse": {
"firstname": "Sally",
"lastname": "Jones",
"totalprice": 992,
"depositpaid": false,
"bookingdates": {
"checkin": "2015-04-17",
"checkout": "2018-03-29"
}
}
},
{
"requestName": "Get a bulk booking",
"bookingId": 2,
"expectResponse": {
"firstname": "Mary",
"lastname": "Jones",
"totalprice": 890,
"depositpaid": true,
"bookingdates": {
"checkin": "2015-08-21",
"checkout": "2016-09-29"
}
}
}