Forum Discussion

harry21's avatar
Occasional Contributor
8 years ago

how to read Rawrequest using Script Assertion while using URI formats in the request ..

My request is in URI format and not Xml. Now i need to read the rawrequest using Script Assertion. I tried this below piece of code. It is working at the Groovy level. But when i used this in Script ...
  • Radford's avatar
    8 years ago

    Sorry, my mistake! I answered if it were a SOAP request, I believe you have a REST request? If so the messageExchange variable is of class RestResponseMessageExchange, I am not sure why the getRequestContent() method is empty (I'm guessing that it's because there is no "content" to your REST request, all the information is in the actual HTTP request)


    The following code:


    def rawRequest = new String(messageExchange.getRawRequestData(), "UTF-8")



    Seems to get what you may be after. The getRawRequestData() method returns a byte array, and then we use the String class constructor that takes a byte array argument to convert to a string (Not sure if there is a more "Groovy" way of doing this conversion).


    Edit: Just wanted to point out that I have made the assumption that the raw request data is UTF-8 I haven't checked this.