Is there an easy way to access parts of an API response in a groovy script?
This is a follow up to my old question - https://community.smartbear.com/t5/API-Functional-Security-Testing/ReadyAPI-How-to-access-the-entire-request-and-response-from-a/m-p/212769. In a groovy script, I would like to be able to access the entire response of an API. For example, like this:
def response = context.expand('Something')
def content_type = response.headers(''content-type")
def name = response.body(jsonPath : students[5th].name)
Is there an easy way to break up a response object into parts like http code, headers, body etc and then extract values from each of these parts? I prefer not to use long and ugly xml like Test#ResponseAsXml/Some long ugly path.
Have a look at the script, hope it helps. follow the comments in the script.
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/AccessResponseData.groovy