Ask a Question

Change a Test Rest Request's link to project's request? "Open Request Editor"

Crazy_Chris
Occasional Contributor

Change a Test Rest Request's link to project's request? "Open Request Editor"

Hello,

 

The problem is that we initially set up each project's Rest Service as a new element.

Now we find that we should have had fewer elements and just add the Ressources etc under one if the endpoint is identical.

 

In SoapUI Pro we have defined a project and several TestSuits each having several Testcases with several Rest Requests linking back to the project.

But I cannot find anyway to change the link from the SoapUI window elements back to the project window elements, am I missing something here? 🙂

 

Thanks for any help understanding this.

7 REPLIES 7
Crazy_Chris
Occasional Contributor

So to add an example:

 

Some REST requests are:

GET myserver.com/{ID_user}

PUT myserver.com/{ID_user}
DELETE myserver.com/{ID_user}
PATCH myserver.com/{ID_user}
POST myserver.com/{ID_user}/verify
GET myserver.com/{ID_user}/verify/{ID_number}
PUT myserver.com/{ID_user}/verify/{ID_number}
DELETE myserver.com/{ID_user}/verify/{ID_number}
 

I tried to make a new REST services under the Projects tab to be able to run tests from SoapUI Pro to those endpoints.

My initial thought was that I could then call these endpoints in test cases as part of a testsuite.

How can I put the {ID_user} value in the URL of a REST resource endpoint to run testcases, it seems to only accept static values and I want to look up random users without predefinding them in a list.

 

Tried setting up the Rest services like this:

Endpoint:                                                                                        Ressource:                                          Parameters:

GET myserver.com/                                                                       {ID_user}

 

Or is my approach totally off? 🙂

If anyone has a better way to pull this off I'd love some input or another approach to dynamic URLs.

Bill_In_Irvine
Contributor

I am running ReadyAPI 2.1.0 - not the latest, which is 2.2, but since no one responded yet, allow me to try.

 

I don't know of how to link back from SoapUI Pro to the Project.

 

I regard the project as a place to set up my APIs (I think you refer to these by "elements."), resources, methods and requests as templates, and the SoapUI for variations on these. In SoapUI Pro I clone the test cases and then edit the cases, maybe add groovy scripts as steps. The groovy scripts of course do not show up in the Project window since it seems to be for setting up REST step templates.

 

But if I understand correctly, you have a whole bunch of APIs - and duplicated endpoints when you can combine them and add numerous resources per API. I am working with my IDE and not a project file but I haven't been able to find how to move a resource between APIs, unfortunately. That is something I guess you want to do.

 

I can only think of biting the bullet and entering the resources by hand to the common element / API.

 

I think it's possible to edit the xml file for the project itself and shift all the common resources to the endpoint/API. But I don't like to monkey with the xml file for the project.

 

 

As for your second post, I would use a Groovy script and use property expansion for ID_user and ID_number. 

 

You can get the resource in the RequestFilter.FilterRequest event handler script with 

String therequestUri = new String(context.getProperty("requestUri").toString())

 and sorry, you need to use string manipulation methods to work with the URL and resource. 

See 

https://community.smartbear.com/t5/SoapUI-Pro/Is-there-any-way-to-get-rest-resource-of-a-rest-step-t...

 

It might be a matter of just appending the property expansion to the URL/resource.

 

Then when that is done, use the context.setProperty("requestUri")   for the new path based on the property expansion for the ID_user.

 

Of course the expansion is done by something similar to

 

def ID_user = context.expand('${#Project#ID_user}')

and then you can do something like therequestUri + ID_user    and that should append the user ID. But this presumes you define the user at the project level. You might find it better to define the user ID at the test case level #testCase#ID_user.

 

I know that this answer is not the specific solution but a start on one approach. Maybe other people have alternatives that are easier. Your project properties ID_user and ID_number might be read off of a Excel spreadsheet. I have not done this.

 

Thank you Bill_In_Irvine,

 

This is a start, I will look into if your suggestions will work.

I was hoping it would be simpler way to just add to an URL but I might think in the wrong direction and just work it out through the testcase as per your suggestion.

 

It would be possible to just get a set of static values in an excel list to read from, but I was hoping to improve the test by getting fresh data.

Template parameters are used to parametrize the request path.

https://support.smartbear.com/readyapi/docs/projects/requests/parameters/types/template.html

 

You can use a test suite or test case property as the input value for that parameter

Crazy_Chris
Occasional Contributor

Hello PaulMS,

 

Thank you for the input.

I looked at this again but could not see a way to add data from a dynamic value received from a POST or GET request.

 

As mentioned I could create a static list from one of the format types(xml, cvs, json)  and in each test, call the same values, but ideally I'd like to call a random value that is newly generated/created. And I cannot figure out how to pass these values to parametrize the request path. As I see it, these parameters need to be created and stored beforehand. 

 

I will admit that I am quite new to Soap, so if I am mistaken if an example could be made I'd really appreciate the assistance.

Thanks!

--

Chris

cancel
Showing results for 
Search instead for 
Did you mean: