tom tom - 1 year ago 98
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 "" (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


Answer Source

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')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download