Forum Discussion

bernhardn's avatar
bernhardn
Occasional Contributor
10 years ago

SoapUI not-Pro: retrieve the completed REST URI

Hi guys,

I need to retrieve the completed URI of a REST request in a groovy script.
There have been two previous posts with the same problem:
viewtopic.php?t=16436
viewtopic.php?t=7016

In each case the solution included an event handler.
Is there a simple way for those of us who dont have SoapUI Pro?

After all, the info is show in request tab 'Raw' at design time (no run required) and is also being logged in the http log at execution time.
example: GET /vibevault/rs/users/581896244222xxx42E04400134BEA65B84/tokens/?tokenType=SSO&tokenDuration=30 HTTP/1.1[\r][\n]

So it should be available without too much effort I suppose. Please let me know.

Many thanks
Bernhard

2 Replies

  • bernhardn's avatar
    bernhardn
    Occasional Contributor
    Hi Ole, Erik,

    I have spent a number of days researching this issue, reading API documentation, this forum, and the web, but no luck -please advise.
    Background info:
    We have a groovy test automation framework, reading test data and verification criteria from an XLS file, executing the tests and then preparing a test report.
    With REST the 'request' is, in most cases, the URI being sent, including host, resource path and parameters (all with expanded values if parameterised).
    This means that if I cant get hold of the 'completed', (i.e. the one being sent) URI, then I have nothing to write into my report about what the test was actually composed of and what parameter values were being used.
    The suite works very well for web services but for REST services I am also keen to provide a meaningful report, not just run the requests.

    I tried a number of methods like testStep.getResource() but they all only return the resource path before any parameter substitution and without the resource parameters and their values.

    Hope you can help.
    Many thanks
    Bernhard

    PS I am using SOAPUI 5.0, free version; our test suites do have a mixture of web and REST services.
  • bernhardn's avatar
    bernhardn
    Occasional Contributor
    For all of you who use SoapUI non-Pro, I finally came up with a solution:

    myURI = testStep.getPropertyValue("Endpoint")+context.expand(testStep.getResourcePath())+mytext.subSequence(0,mytext.size()-1)

    with mytext built like this:

    mypropnamelist = testStep.getResource().getPropertyNames();
    mytext = "?";
    for (xx=0;xx<mypropnamelist.size();xx++){
    mytext = mytext + mypropnamelist[xx] + "=";
    mytext = mytext + context.expand(testStep.getPropertyValue(mypropnamelist[xx])) + "&"
    }

    Even the sorting of the parameters corresponds to the one used in the teststep (i.e. is not alphabetical).

    Enjoy
    Bernhard