tom tom - 1 month ago 19
Groovy Question

Stripping quotes from response and transferring to request endpoint

I'm using SoapUI for testing some REST api. As a response I'm getting the URL that should be an endpoint of the next request.

I made the following Property Transfer step

source : myApiCall
property : response

target : myHttpCall
property : endpoint


Everything would be ok, but when transferred the endpoint looks like "www.myurl.com" (with quotes) and thus is invalid. How do I strip the quotes from there?

Raw response :

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 98
Content-Type: application/json; charset=utf-8
Expires: Tue, 25 Oct 2016 09:04:28 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 25 Oct 2016 09:04:28 GMT

"http://myurl.com/query?queryUid=90e97bdb-00a3-47c2-8809-c15ceec6ea1b"

Answer

Seems that since your response is directly a string it can not be do it using property transfer, try with Groovy script testStep:

// get your api call
def myApiCall = context.testCase.getTestStepByName('myApiCall')
// get the raw response
def responseUrl = myApiCall.getPropertyValue('Response')
// since your response contains the `"` remove it
responseUrl = responseUrl.replace('"','')
// set the endpoint correctly
def httpCall = context.testCase.getTestStepByName('myHttpCall')
httpCall.setPropertyValue("endpoint",responseUrl)