Forum Discussion

SriniMarva27's avatar
SriniMarva27
Occasional Contributor
7 years ago

How do I retrieve Raw Request using Context variable in Groovy?

Is there a way I can get the Raw Request contents using Context variable in Groovy? If so, how do I achieve this?

3 Replies

  • New2API's avatar
    New2API
    Frequent Contributor

    SriniMarva27, did you try 

     

    def TestStep = context.getCurrentStep()
    def RestStepName = TestStep.getLabel()

     

    context.expand('${'+RestStepName+'#RawRequest}')   

     

    or simply

     

    context.expand('${MyTestStepName#RawRequest}')   

     

    I think this one will give you only payload information.

     

    • SriniMarva27's avatar
      SriniMarva27
      Occasional Contributor

      log.info "Request is: "+context.expand('${GetRebates#Request}')
      log.info "Raw Request is: "+context.expand('${GetRebates#RawRequest}')

       

      Both the lines of code returns me the same content.

  • nmrao's avatar
    nmrao
    Champion Level 3
    if use script assertion for the same request test step then below should do:

    log.info context.rawRequest