Iteration and Looping conditions

I am writing a scenario in java. My problem statement is:

The values from response of API A is stored into two list accountType and accountId. I want to iterate over accountType list and say if accountType is X execute API B , if accountType is Y execute API C , if accountType is Z execute API D.
List accountType can have one or two or three values.

It will be helpful if you show example of response including most complicated payload.

You can use any of Conditional statements - example of use doSwitch below:

Response from API A:

{
“accounts”: [
{
“accountID”: “123”,
“status”: “ACTIVE”,
“accountType”: “X”
},
{
“accountID”: “456”,
“status”: “ACTIVE”,
“accountType”: “Y”
},
{
“accountID”: “789”,
“status”: “ACTIVE”,
“accountType”: “Z”
}
]
}

Now if account type is X exec API B with request body

{“accountId”: 123}

if account type is Y exec API C with request body

{“accountId”: 456}

Also it is not necessary that response of API will always have all three account types.

pseudo code:

1 Like

I have created example for your Case → Case0024IterationLoopCondition

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.