cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Occasional Contributor

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

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

3 REPLIES 3
Highlighted
Frequent Contributor

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

@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.

 

Highlighted
Occasional Contributor

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

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.

Highlighted
Community Hero

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

if use script assertion for the same request test step then below should do:

log.info context.rawRequest


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite