Get MockResponse as a String in the Response script
Hi Everyone,
Not sure if this question has never been asked before. If so, please provide me with an approproate address.
I need to set a MockService property from a MockResponse, so that I can use it in the dispatch script for the next mock operation.
For that I am trying to read the response as a string and put a value from that response to the MockService property.
How can I get my response as a string in this case?
I tried to look here for an answer https://www.soapui.org/rest-testing-mocking/mock-service-scripting.html but to no avail.
Here is what I've tried:
https://www.soapui.org/apidocs/com/eviware/soapui/model/mock/MockResponse.html#getResponseContent()
def response = MockResponse.getResponseContent(); String id = response.Flights[0].Id; log.info(id); def mockService = mockRunner.mockService; mockService.setPropertyValue("myId", id);
Also, I tried to use json slurper to parse the response as a text as I do in testcase scripts and assertion scripts.
Neither of these seem to work, though.
I am pretty sure the answer should be quite obvious, but I cannot find it for some reason.