Forum Discussion

NAVTEQ_Support_1's avatar
NAVTEQ_Support_1
Contributor
14 years ago

Reding REST URL with fully expanded properties

Hi,

I’m facing problem to get full URL for REST request with Groovy. This is the code:

import com.eviware.soapui.impl.wsdl.teststeps.*
for( testStep in testRunner.getTestCase().getTestStepList() ) {
def endpoint = testRunner.testCase.testSteps[testStep.getLabel()].getPropertyValue("Endpoint");
def path = testRunner.testCase.testSteps[testStep.getLabel()].getResource()
log.info context.expand(endpoint + path.getFullPath(true) );
}

However, this approach returns following output:
Wed Sep 14 12:52:59 CEST 2011:INFO:http://localhost:8080/layer/{id}/{objectId}

Obviously, I'd like to see the id and objectId properties expanded into their actual value and receive http://localhost:8080/layer/street/911

Getting values for properties with: “testRunner.testCase.testSteps[testStep.getLabel()].getPropertyValue("id")” is possible of course but I would like to know if there is simpler way to do this, read the actual URL fully interpreted, it has to be there somewhere...

Thanks,

roman
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    You can use the RestUtils class to get this from the RestRequest:


    import com.eviware.soapui.impl.rest.support.RestUtils

    def request = testRunner.testCase.testSteps['Method 1 - Request 1'].testRequest

    log.info RestUtils.expandPath( request.resource.fullPath, request.params, request )


    Note that "request" in this case refers to the TestRequest of a RestTestRequestStep. Good luck!

    Regards,
    Dain
    SmartBear Software
  • Thanks for the answer, works as a charm!

    If I may have a follow-up for this: is it possible to read also media type and accept settings for a REST request which I'm sending? We have requests with various settings so we need to individually read them when we work some advanced magic there Thanks,

    roman