Forum Discussion

payalsobti's avatar
payalsobti
Occasional Contributor
13 years ago

[Resolved] How can I retrieve Raw response

Hi,

I would like to retrieve the raw response, i tried using the code you suggested in one of your response but i am getting "An error occured [No such property: messageExchange for class: Script1], see error log for details"

Please suggest,
Payal

log.info messageExchange.getResponseContent().toString() // <- you've probably seen this one

for (header in messageExchange.getResponseHeaders())
log.info header //<- prints all headers

log.info new String(messageExchange.getRawResponseData()) // <- this is raw response data

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    can you try wrapping that line in 'new String(..)' call, so it gets converted to string value, i.e.
    new String(testRunner.testCase.testSteps["login"].testRequest.response.rawResponseData)

    Hope this helps,
    Vladimir
    SmartBear Software
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    where are you running this script? If it is in a standalone groovy script you need to get hold of the actual response for the corresponding TestStep first, ie

    def rawResponse = testRunner.testCase.testSteps["Request 1"].testRequest.response.rawResponseData

    Does that help?

    regards!

    /Ole
    SmartBear Software