Ask a Question

How to get complete RawRequest as shown in ReadyAPI GUI?

SOLVED
amirse
Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Nastya_Khovrina
Moderator

Re: How to get complete RawRequest as shown in ReadyAPI GUI?

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)

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

2 REPLIES 2
Nastya_Khovrina
Moderator

Re: How to get complete RawRequest as shown in ReadyAPI GUI?

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)

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
amirse
Contributor

Re: How to get complete RawRequest as shown in ReadyAPI GUI?

Hi,

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

cancel
Showing results for 
Search instead for 
Did you mean: