Iterating Checkpoints for REST API using Select Data to define expected results and iterations

Created a REST API test in UFT 14.00. The records returned for the GET request need to be dynamic so I am using a SQL query to get the records that should match the results from the REST request. I am linking the checkpoints to the Select Data action to validate the results of the REST request. When I link the data source from the REST checkpoint to the Select Data action, I am getting validations and an option to run validations for all of the rows returned by the query run in the Select Data action. Unfortunately, each iteration of the loop for the REST Method runs the full set of iterations returning results for all checkpoints in each checkpoint. I am trying to figure out how to configure the Test Flow to iterate as many times as there are rows of data returned by the query in the Select Data action. I hope this is clear, if not just let me know what else you need to know to help. Thanks in advance. 

  • Hello,

    Let me make sure if I understand your question correctly. Correct me if I missed anything.

    You have a query to the database done by 'Select Data' action and it has a number of rows. You want to do the same number of REST requests and have the checkpoints point to the corresponding rows of the data results.

    If that's the case, please try the following steps to see they can help.

    1. There's a default 'Test Flow' in the canvas. Put the 'Select Data' action above it.

    2. Click 'Test Flow' and point the number of iterations (from 'Properties' pane) to the output parameter 'Count' of 'Select Data'.

    3. Put the REST action within the 'Test Flow'. Now it'll run the same time as the number of rows of the selected data.

    4. In the checkpoint, click 'Link to data source' button and it'll pop up a dialog for selecting the binding source.

    5. In the dialog, click 'Custom Expression' button in the bottom. Select one item of the result table of 'Select Data' and click 'Add' button in the custom expression area. It'll create a binding expression like this: {Step.OutputProperties.DbFetchData10.ResultTable.Row[1]}

    6. Move the cursor to the index of the Row and clear the '1'. 

    7. Select 'Test Flow' above and select it's property 'Current iteraction number'. Add it to the current cursor of the custom expression. It'll be like this: {Step.OutputProperties.DbFetchData10.ResultTable.Row[{Step.OutputProperties.Loop2.CurrentIterationNumber}]}

    8. You may need to pick the field of the row to match the response of the REST request.




  • Hi,

    I am new to API testing and am trying to solve an issue. 

    I have a script that queries the database and brings back about 5 columns. i have set it to correct iterations and loops. I want to save the column data returned in the Result table into the local datatable . How can i achieve this?

    I can get the entire resultset , i printed it using the ReportMesssage like this

    <Row><clientid>XXXX</clientid><clientname>ABCD NAME</clientname></Row>

     , but am unable to get the value for each column into an excel or data table, so i can use it for adding checkpoints later in the script.

    can anyone point me in the right direction?



  • Hi,

    If you want to use the queried result as a resource, you can add a database data source to an API test.

    Here is the UFT online help about this topic.

    Hope this may resolve your question.




  • Thanks!! i was able to fix the problem and it works now, when i get 1 row back from the database.

    i now have a need to run a query which will return multiple rows and i want to then use this for the API checkpoints.

    So i have multiple rows for the criteria used - Name = XYZ, ABC, UFT

    Each Query returns multiple rows - example where name like 'XYZ' returns 10 rows with 5 columns of data. 

    For name like 'ABC' - i have 5 rows returned ..etc.

    How do i add checkpoints for my API? 

    i have the outer and inner loops all working and i can see it runs through the exact number of Iterations for the SQL query result count, and then loops through the REST API for each row returned by the query.

    But on my next iteration, the JSON Object is empty. i want to check the JSON response and validate the data matches the data returned in my query.

    can someone please help?




  • Could you please provide a snapshot of your scenario and issue you get?
    I do not quite get you.



  • Hi,

    Here is my scenario of what i want to achieve -
    i have an API response which will bring multiple rows of data for an id search.

    i want to validate these values against the database values returned for the same id.

    For my checkpoint, i am pointing the JSON object row value against the databsae field value, and set it to run through all arrays of the JSON object returned.

    The ids are stored within a DataSource column I created. This way i can run the same scripts for various Ids. But each id returns different rows.

    If i use the Reload from Play to validate the object, it only loads the last iteration rows (which for example may only have had 11 rows returned). So when the test flow loop runs the 2nd time with an id that will return say 25 rows of data, my script fails the checkpoint, saying the array is empty.

    how can i make it dynamic for adding checkpoints?

    this is my first time with UFT API and appreciate any help!!