Forum Discussion

rajs2020's avatar
rajs2020
Frequent Contributor
4 years ago

ReadyAPI - How to access the entire request and response from a Groovy script?

Inside a groovy test step, is it possible to access the entire request and response data from a previous REST API test step? If yes, then how do we access the request and response?

  • rajs2020 : Yes it is possible to get the request and response of any test step refer below code sample:

     

    def request = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Request")
    def response = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Response")
    
    log.info request
    log.info response

    Let me know in case more help you needed.