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 Assertion (at the teststep level) it is failing.. i'm not getting the result
def request = testRunner.testCase.getTestStepByName("Request").getHttpRequest().getRequestContent()
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") log.info(rawRequest)
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.