Forum Discussion

adam10973's avatar
New Contributor
8 years ago

Parse REST request in Mock Response?

I am trying to parse a rest request in a Mock Response. The request looks something like:




The SoapUI documentation for MockService Scripting looks like it only covers parsing SOAP XML requests, e.g.:


def groovyUtils = new (context)
def holder = groovyUtils.getXMLHolder( mockRequest.requestContent )

def item1 = holder.getNodeValue("//item1")


However, the REST request doesn't come in as XML, so the above doesn't work.


Right now I'm using:


def item1 = mockRequest.getPath().tokenize('/')[1]
def item2 = mockRequest.getPath().tokenize('/')[3]


Is there a better way to do this? Perhaps by calling something like:


def item1 = mockRequest.getProperty("item1")


Or something like that?

1 Reply

  • nmrao's avatar
    Champion Level 3
    If possible show the sample data closer to your request and what data you need to extract?