Forum Discussion

amirse's avatar
amirse
Contributor
7 years ago

How to get complete RawRequest as shown in ReadyAPI GUI?

Hi,

I am using following code to get raw request created in ReadyAPI:

 def rawRequest = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getPropertyValue("RawRequest")
log.info("rawRequest = " + rawRequest)

 

I use the same code to get raw response

 def rawResponse = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getPropertyValue("RawResponse")
 log.info("rawResponse = " + rawResponse)

 

Now, the problem is that the rawRespons prints all the text as shown in the ReadyAPI GUI (including HTTP/1.1 200 OK...) but rawRequest shows only parts of request. Depending on what I do sometimes I get some output and sometimes, as in attached picture, it is empty EVEN though the GUI shows there is text there. See attached picture

 

Anyone that can tell me if it is possible to get complete request in the same way as the reponse regardless how much or little info is stated there?

 

Thanks in advance.

  • Hi amirse,

     

    To get the raw request you can use the following script in the Groovy Test Step:

     

    def myRequestStep = testRunner.testCase.getTestStepByName('TestStepName')
    def GetrequestData = new String(myRequestStep.testRequest.messageExchange.rawRequestData)

    or, the following code in the RequestFilter.afterRequest and RequestFilter.filterRequest events:

    byte[] rawRequestData = request.getResponse().getRawRequestData()
    request = new String(rawRequestData)
    log.info(request)

     

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    Hi amirse,

     

    To get the raw request you can use the following script in the Groovy Test Step:

     

    def myRequestStep = testRunner.testCase.getTestStepByName('TestStepName')
    def GetrequestData = new String(myRequestStep.testRequest.messageExchange.rawRequestData)

    or, the following code in the RequestFilter.afterRequest and RequestFilter.filterRequest events:

    byte[] rawRequestData = request.getResponse().getRawRequestData()
    request = new String(rawRequestData)
    log.info(request)

     

    • amirse's avatar
      amirse
      Contributor

      Hi,

      Thanks for you reply. It helped me to solve my issue. I will close this post.