REST API - dynamically test all elements of an array response

I want to test an API function that returns an array of contacts in JSON. Depending on who is making the request, the array will contain different results. The array looks something like this:

{
“contacts”: [
{
“firstName”: “John”,
“lastName”: “Smith”,
“phoneNumber”: “555-1234”
},
{
“firstName”: “Sarah”,
“lastName”: “Connor”,
“phoneNumber”: “555-4321”
},
{
“firstName”: “Steve”,
“lastName”: “Stephens”,
“phoneNumber”: “555-2222”
}
]
}

I want to write a single test case, and pass in the expected results as a variable to that test case. Depending on other factors, the results list could be n elements long and I want to be able to test all of them. Ideally I would like to pass in a variable that is a list of maps, and iterate through it with a for loop. Unfortunately it doesnt seem like a list of maps is possible in Katalon, is there another way to do this? I would prefer not to write multiple test cases that all do essentially the same thing but with different response lengths

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Hi @ross.kuhlman,

Welcome to our community. There are a lot of experts here can help you

1 Like