Forum Discussion

cpgutierrezm's avatar
cpgutierrezm
Occasional Contributor
7 years ago

Pass a String array into a get request

Hello,

 

I need to pass a String's array to the item "acctNo". I mean, each value has an entry parameter "acctNo=660016A&acctNo=66000XW", but this is not working.

 

/portfolio-rs/v1/1/accounts/assetsDetail?acctNo=660016A&acctNo=66000XW&livePrice=true&buyingPower=true

 

Instead, by using another online tool the same request, it works.

 

Please, any clue ?

 

Thank you so much !

 

  • richie's avatar
    richie
    7 years ago

    aaah - I see

     

    I didn't see the second Accno query parm

     

    The trouble with this is that SoapUI doesn't recognise it as different query parameter - and so doesn't allow you to add in duplicates.

     

    Someone else asked something similar a couple of weeks ago I believe - but there's no way around it as far as I can tell.

     

    The trouble is a GET query is like a SELECT query against a database.

     

    Currently your GET if you considered it as SQL would appear as follows:

     

    SELECT * FROM TABLE

    where accNo = '66000XW'

    and accNo = '660016A'

    and livePrice = 'true'

    and buyingPower = 'true';

     

    and the above would be invalid - if accNo is unique - then you would never get a single record because you are trying to find a record where accNo is both '66000XW' and '660016A'

     

    I'm guessing from your request - you are trying to retrieve more than 1 record - i.e. 2 different account records where livePrice=true and buyingPower=true?

     

    so the SQL equivalent  would be as follows:

     

    SELECT * FROM TABLE

    where accNo in ('66000XW', '660016A')

    and livePrice = 'true'

    and buyingPower = 'true';

     

    This requires either altering the URI (to allow parameterization in SoapUI)  or hardcoding your request.

     

    If you just want to inject this via SoapUI - you bodge it - so select to create a new resource from the URL and paste in the URL up to but not including the query parms

     

    e.g. https://domainname.com/

     

    then once the resource has been created, you can then paste in the remainder of the URL (/portfolio-rs/v1/1/accounts/assetsDetail?acctNo=660016A&BacctNo=66000XW&livePrice=true&buyingPower=true) into the 'Resource' field.

     

    Then within the test case, click to create a new REST request, and select this option from your listing - this would allow you to submit the request from SoapUI but doesn't provide any of the advantages of using SoapUI above other REST client tools - SoapUI lends itself to parameterization and automation.  Essentially the approach I've just described hardcodes the values in - and so provides no advantages from using SoapUI compared with a different tool.

     

    That kindof highlights why REST URI design is so important and needs to be reviewed early in the design/development stages so that problems like this don't occur.

     

    I'm sorry I can't be of more help.

     

  • richie's avatar
    richie
    Community Hero

    Hi,

     

    I'm struggling with the info provided - are you saying you have a REST request with a 3 query parameters as follows:

     

    /portfolio-rs/v1/1/accounts/assetsDetail?acctNo=660016A&acctNo=66000XW&livePrice=true&buyingPower=true

     

    So you are struggling to set this up within  ReadyAPI!/SoapUI?

     

    Is that correct?

     

    If you just follow the standard instructions to create a new GET REST request - i.e. within your project, right click to launch the context menu and select 'New Rest Service from URL' then paste in the full URL (the query parms) - SoapUI will split the parms for you.

     

    At that point, I then highlight the 'Resource' and then click on the Parameters button just to be sure - you should see 3 query parms

     

    1.acctNo

    2.livePrice

    3.buyingPower

     

    Then within the test suite you can then use properties to populate the query parm values accordingly.

     

    Other than that I'm a little lost as to what you are asking ?

     

    Cheers,

     

    richie

    • cpgutierrezm's avatar
      cpgutierrezm
      Occasional Contributor

      In fact, I did what you have described and yes I got the three parameters.

      1. acctNo (array String)

      2. livePrice

      3. buyingPower

       

      But, I have the problem when I use the acctNo with more than two values. And I am sure the chain should works like it works over other online Tools

       

      /portfolio-rs/v1/1/accounts/assetsDetail?acctNo=660016A&acctNo=66000XW&livePrice=true&buyingPower=true

       

       

       

       

       

      • richie's avatar
        richie
        Community Hero

        aaah - I see

         

        I didn't see the second Accno query parm

         

        The trouble with this is that SoapUI doesn't recognise it as different query parameter - and so doesn't allow you to add in duplicates.

         

        Someone else asked something similar a couple of weeks ago I believe - but there's no way around it as far as I can tell.

         

        The trouble is a GET query is like a SELECT query against a database.

         

        Currently your GET if you considered it as SQL would appear as follows:

         

        SELECT * FROM TABLE

        where accNo = '66000XW'

        and accNo = '660016A'

        and livePrice = 'true'

        and buyingPower = 'true';

         

        and the above would be invalid - if accNo is unique - then you would never get a single record because you are trying to find a record where accNo is both '66000XW' and '660016A'

         

        I'm guessing from your request - you are trying to retrieve more than 1 record - i.e. 2 different account records where livePrice=true and buyingPower=true?

         

        so the SQL equivalent  would be as follows:

         

        SELECT * FROM TABLE

        where accNo in ('66000XW', '660016A')

        and livePrice = 'true'

        and buyingPower = 'true';

         

        This requires either altering the URI (to allow parameterization in SoapUI)  or hardcoding your request.

         

        If you just want to inject this via SoapUI - you bodge it - so select to create a new resource from the URL and paste in the URL up to but not including the query parms

         

        e.g. https://domainname.com/

         

        then once the resource has been created, you can then paste in the remainder of the URL (/portfolio-rs/v1/1/accounts/assetsDetail?acctNo=660016A&BacctNo=66000XW&livePrice=true&buyingPower=true) into the 'Resource' field.

         

        Then within the test case, click to create a new REST request, and select this option from your listing - this would allow you to submit the request from SoapUI but doesn't provide any of the advantages of using SoapUI above other REST client tools - SoapUI lends itself to parameterization and automation.  Essentially the approach I've just described hardcodes the values in - and so provides no advantages from using SoapUI compared with a different tool.

         

        That kindof highlights why REST URI design is so important and needs to be reviewed early in the design/development stages so that problems like this don't occur.

         

        I'm sorry I can't be of more help.