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/as...
  • 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.