We are using Karate, to automate API. Where In last I want to clean all the test data which has been created by Automation suite. by using below scenario - first we will get all the profiles which we have created thru automation - and then we will execute delete API for each profileID
Scenarios till now :
@DeleteAllProfile
Scenario: Get Profile list -> Apply filter to ignore Default profile -> Delete each Profile
Given path '/profiles'
When method GET
Then status 200
* def children = $response[*].profileId
Children is the object which consists all the profileID for example : ["AutoProfileId758", "AutoProfileId169", "AutoProfileId90", "AutoProfile59", "AutoProfile10", "AutoProfile64", "AutoProfile44" ]
Now we need to call delete API on each profile,
Given path '/profile/'+ x
When method DELETE
Then status 204
X is the value which I want iterate from children object and length of x will be dynamic
Any method to achieve this?
I tried to write below code
* def fun = function(x){
Given path '/profile/'+ x
When method DELETE
Then status 204}
* karate.forEach(children, fun)
But its doesn't work