Ask a Question

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

SOLVED
Gautam
Occasional Contributor

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

2 ACCEPTED SOLUTIONS

Accepted Solutions
rupert_anderson
Valued Contributor

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

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

 

 

Author of SoapUI Cookbook

View solution in original post

Gautam
Occasional Contributor

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

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

View solution in original post

9 REPLIES 9
rupert_anderson
Valued Contributor

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

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

Author of SoapUI Cookbook
Gautam
Occasional Contributor

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

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
Valued Contributor

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

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

Author of SoapUI Cookbook
Gautam
Occasional Contributor

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

Hi Rupert,

 

Thanks a lot for your help!!

 

Now, I am able to store the URL in property file successfully. I am using HTTPeditor to trigger the url's stored in a property by using ${base_url}.

I have landed into another trouble, please help me out of it:

1. When i click on submit button in HTTP request,  i am getting Input validation failure error.

2. When i copied the same URL from property and tried to open it in internet explorer, i am getting expected JSON response.

3. On further analysis, i found in raw request that my URL is incorrect during submission. Instead of "%20" tags for space " %2520" is present and all the alphabets in URL which are in Upper case are changed to smaller case automatically.

Is this a bug or am i missing something here?

Is there any way to handle this behavior so that i can trigger the correct expected URL to get JSON response?

 

Please find below the screenshot of changes to the URL.

 

IssuesScreenshot.PNG

 

Thanks,

Gautam

rupert_anderson
Valued Contributor

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

Hi Gautam,

 

Well done! Sounds like you're really getting there!

 

Unfortunately, I have also found the HTTP TestStep UI converting things to lowercase to be a annoying issue! I thought using a property expansion to set the whole url might work arround it? (http://community.smartbear.com/t5/SoapUI-Open-Source/In-HTTP-Test-Requests-only-it-appears-Request-U...

 

Cheers,

Rupert

Author of SoapUI Cookbook
Gautam
Occasional Contributor

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

Hi Rupert,

 

Thanks, all credit goes to you as i followed steps which you guided me to. Just that i found it is not working as expected.

 

Yes, i have broken the URL where %2025 is coming into 2 parts and using 2 variables instead of one. It is a temporary workaround. Hope the Soapui Team solves this issue soon.

 

Can you please tell me the process to highlight this issue to the SOAPUI Team.

 

Once again, Thanks a lot for your help. Really appreciate it.

Before posting to the forum i thought i wont get even a single reply, but now i am happy that i found out a sloution (temporary) to it.

 

Thanks,

Gautam

rupert_anderson
Valued Contributor

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

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

 

 

Author of SoapUI Cookbook

View solution in original post

Gautam
Occasional Contributor

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

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

View solution in original post

rupert_anderson
Valued Contributor

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

Hi Gautam,

 

Nice one! Will be good if you can get this change done!

 

Thanks again,

 

Cheers,

Rup

Author of SoapUI Cookbook
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β