Forum Discussion

Sirisha2020's avatar
Sirisha2020
Contributor
5 years ago

How to save the request and response in a folder along with time stamp

Hi I am trying to save the request and response in a folder along with time stamp. I am able to save the response with timestamp. But request is saving with empty file. please find the below code :...
  • sonya_m's avatar
    sonya_m
    5 years ago

    Hi Sirisha2020 !

     

    This query involves custom scripting, let's see if what I found would be of help!

     

    This script gets the request data and raw response with headers:

     

    def myRequestStep = testRunner.testCase.getTestStepByName('TestStepName')
    def GetrequestData = new String(myRequestStep.testRequest.messageExchange.rawRequestData)
    def GetresponseData = new String(myRequestStep.testRequest.messageExchange.rawResponseData)
    log.info  ("Request = " + GetrequestData)
    log.info  ("Response = " + GetresponseData)

     

    You can try to modify this script to see if that would fit your needs!