Forum Discussion

lgermain315's avatar
lgermain315
Occasional Contributor
6 years ago

Accessing data content using "RawRequest" variable returns null even though a request object present

Using version 2.4.0, I have test that fail now because the "RawRequest" data is null.

 

In the past when you, use "Get Data" you could access the request body and use that variable for an asserions. It seems that this "RawRequest" variable is null.

 

Could there be a setting that I need to enable to access the request body? I have test history disabled and max results set to 1.

 

Video Showing the Issue trying to access "RawRequest"

https://www.screencast.com/t/RaNIsVjb

 

thanks,

 

Luke 

 

5 Replies

  • Hi lgermain315

     

    Just write down below code in groovy script and you will get RawRequest Data

     

    def getRequestData  = new String(getRequestTestStep.testRequest.messageExchange.rawRequestData)
    
    log.info getRequestData  

    For GET Type Request RawRequest is empty and there is no such setting i have found till now by which we can get the RawRequest for GET Type.

     

    Do like and accept if you find it as solution!!

     

    Thanks,

    Himanshu

  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    after your step running and then you can get RawRequest from property

    def rawRequest = context.expand('${#YourStepName#RawRequest}')

    "Get data" shortcut also can retrieve RawRequest

     

    ${YourStepName#RawRequest}

     

    Regards,

    /Aaron

    • HimanshuTayal's avatar
      HimanshuTayal
      Community Hero

      Hi aaronpliu

       

      But if you are working with RESTful and method is GET, in that case RawRequest is not available.

      In any other scenario it will work fine.

       

      Thanks,

      Himanshu Tayal

      • lgermain315's avatar
        lgermain315
        Occasional Contributor

        Hi,

         

        Thanks for your feedback, however these seem to be work arounds for the problem. The original functionality that was in place seems to have been broken.

         

        Here's another video that shows the desired behavior:

        https://www.screencast.com/t/CKKqCa3vXQu

         

        UPDATE:

        I found that my request object had 1 trailing comma which caused the json to be invalid. Version 2.2  ignored this comma and version 2.4 does not and writes an error to the log. Once that comma was removed, the 'RawRequest' dialog showed up and worked as expected.

         

        However, there are still issues using "Select Content" drop-down within the asserion dialog. I will not use this anymore. Instead use the right-click context menu "Get Data" and use that dialog to achieve the desired results.