Forum Discussion

Ramsiya's avatar
Ramsiya
Occasional Contributor
12 months ago

Readyapi

Is it possible to include more than one data source in a single request? For instance, I would like to execute the Guid data source to change the tracking ID, and I need Excel to read the values
  • richie's avatar
    richie
    Community Hero

    Hey Ramsiya 

     

    I've never tried - the steps in a test run sequentially so strictly speaking I'm guessing you could have multiple datasources in the sequence before your executable test step - i.e. see as follows:

     

    -TestSuite

    --TestCase

    ----DataSource1 (read values from Excel)

    ----DataSource2 (GUID generator)

    ----Executable Step (REST Request?)

     

    The above would work as the steps execute sequentially

     

    I've just thought you might be looping your testcase (if you are using looping (and if you're reading from an Excel datasource then I'm guessing you are) and at first I was doubtful whether it would work - but after thinking I still think it would work fine with looping as long as you specified the first DataSource (DataSource1) as the LoopStep's DataSource.

     

    If I understand correctly (and I could be wrong) and are using the GUID datasource to create GUID values and you want to read values from an Excel spreadsheet to populate your executable test step - then instead of having the GUID Generator datasource - you could use the dynamic snippet of the following:

     

    ${=java.util.UUID.randomUUID()}

     

    if you have rows of data in a spreadsheet you could add this snippet in as another value for each row in your spreadsheet

     

    This Java snippet dynamically generates type4 GUIDs/UUID values when processed by ReadyAPI.

     

    i.e. if I save this as a testcase property value and then within my request's payload for the specific json attribute I point to the testcase property and when executed - it generates a GUID/UUID in the request payload.

     

    Cheers,

     

    Rich

     

      • richie's avatar
        richie
        Community Hero

        Hey @Ramsiya

        Apologies - I got locked out of the forum when it changed - have you got yourself sorted or do you need me to still supply a screenshot for a possible solution?

        Cheers,

        rich

         

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

    richie is correct.  You can obtain values from several data sources and it does work.  richie's point around ensuring the data source nesting is correctly wired up is the biggest factor.

    richie also makes an excellent point around using the UUID generator.  Might save you some effort.