Forum Discussion

Gautam's avatar
Gautam
Occasional Contributor
10 years ago

Parametrizing Endpoint, Resource/Method and paramter values in rest URL

I am new to Rest services testing!! Plz help on hw to parametrise the Endpoint, resource/method and paramters in rest URL. I want to pick the fully qualified application URL (ENDPOINT+RESOURCE/METHOD+PARAMETERS) from excel, pass it to a property and then trigger it to REST request header. Tell me if its possible and if yes, how?

 

Thanks,

Gautam

  • Hi Gautam,

     

    Thats great! You've done well to work through it all and pick up he skills you need, I hoped you would! :-)

     

    I'm delighted if I've helped increase your faith in the community, whilst not everything gets answered, as most people are volunteers with other jobs etc, its great to hear positive things about it!

     

    Workaround sounds sensible - I have never actually reported a bug to the SoapUI team, I would have to ask Rao (nmrao) or one of the other community experts, I am actually relatively new to the community... I definitely think the HTTP url to uppercase issue should be easy to fix, whilst they may not see it as a bug, it is definately anooying and has come up before, so am happy to back you up if you want to report it. There is a feature request area, possibly a quick post in there and they can move it if not appropriate?

     

    One last thing, if you're happy that your original question is solved then please can you mark the question as solved?

     

    Nice working with you!

    Cheers,

    Rup

     

     

  • Gautam's avatar
    Gautam
    10 years ago

    Hi Rupert,

     

    Just FYI, i have raised request 00120907 for technical enquiry of the issue. If i receive any reply from the SOAPUI team, i will update on this,.

     

    Thanks,

    Gautam

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi Gautam,

     

    Yes, it is very doable and popular to do file based data-driven testing in open-source SoapUI, it basically involves Groovy scripting (Groovy Scrip TestStep) and property expansions (http://www.soapui.org/scripting---properties/property-expansion.html).

     

    You will see a variety of solutions, they are generally similar in pattern e.g.

     

    1.read a row of data for the file

    2.populate the (REST or HTTP) Test Request TestStep using property expansions to insert the file data values into the request.

    3.loop until there are no more rows.

     

    Here are some example posts to look at:

     

    http://community.smartbear.com/t5/SoapUI-Open-Source/Setting-parameter-in-REST-post-xml-mesage-and-c...

     

    http://community.smartbear.com/t5/SoapUI-Open-Source/Groovy-script-for-dynamically-getting-and-setti...

     

    This site is also popular:

     

    https://learnsoapui.wordpress.com/2012/05/19/groovy-datasource-teststep-dataloop-teststep-using-groo...

     

    And also my book! :-)

     

    In terms on which TestStep to use e.g. REST or HTTP, sometimes the HTTP TestStep can be more convenient (second post above) when you want to control the entire URL. Depends on your service really...

     

    Let me know if you need any more help with the Groovy etc. 

     

    Cheers,

     

    Rupert

    • Gautam's avatar
      Gautam
      Occasional Contributor

      HI Rupert,

      Thanks for your reply!!

      1. I am trying to take endpoint, resource/methods and paramters values from excel sheet, combining them to make URL as endpoint\resource?parameters and saving it in a property in SOAPUI.
      2. From soapui i login to the application successfully and come to the landing page of application.
      3. When i use this property which has URL value and call it in the REST editor in place of endpoint, it is not returning anyhting. (when i append cookie information i am getting a response (not sure if valid or not)).

       

      As i am new to REST services, i am unable to figure out a way to use dynamic URLs so that i can trigger 100+ urls with one REST request step in same session without logout from my application.

      The links which you have shared are going above my head....:(

       

      Hope i am able to express my problem scenario properly!! Please help me with a small and simple example.

       

      Thanks,
      Gautam

      • rupert_anderson's avatar
        rupert_anderson
        Valued Contributor

        Hi Gautam,

         

        Ok, if I'm understanding you correctly then maybe theres a few areas to discuss.

         

        So, for point 1, this is what I was meaning by data-driven testing. In SoapUI open source this is generally achieved using Groovy scripting, which is what I was trying to help with in my first reply. Only SoapUI pro and Ready! API i.e. commercial versions feature DataSource, DataGen & DataLoop TestSteps e.g. a way to support data-driven testing out-of-the-box, but it the Groovy scripting option really isn't as bad as it may look to you at first glance. So if you'd like to ask me any questions about it, I'd be happy to try and explain?

         

        Certainly if you wish to supply endpoints,resoures & parameters from a spreadsheet to make your REST calls then maybe it would be eaiser to use HTTP Test Request TestSteps, rather than REST TestSteps, as it is sometimes easier to parameterise and build the entire URL for the HTTP TestStep. So if you have something like:

         

        Screen Shot 2015-07-23 at 22.17.11.png

         

        Then in first Groovy TestStep, read a row of test data (see links in first reply for more on this or ask), then use the data to build your url e.g. you can store the url in the context holder / map which is passed between TestSteps:

        context["urlString"]="http://host.com/resource"

         

        Then you can use this urlString value to set the url of the next HTTP TestStep e.g. using the property expansion ${urlString}

         

        Screen Shot 2015-07-23 at 22.24.21.png

         

        Finally use a Groovy TestStep to loop back to the first Groovy TestStep e.g.

         

        if (last row of data...) testRunner.gotoStepByName("Get Next Row Of Data & Build Endpoint Param")

         

        Obviously there are more details than this, the 4th link in my original reply might help there or ask...

         

        To address point 3 i.e. maintaining session after you login, have you seen the TestCase property to 'Maintain HTTP session' (see below)? 

         

        Screen Shot 2015-07-23 at 22.08.55.png

         

        This is very useful when you need to login/authenticate once and then make a series of requests using the same session, without the need to login again.

         

        Any more questions let me know,

         

        Cheers,

        Rupert