Ask a Question

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

lgermain315
Occasional Contributor

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 5
HimanshuTayal
Community Hero

Re: Accessing data content using "RawRequest" variable returns null even though a request

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


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
aaronpliu
Frequent Contributor

Re: Accessing data content using "RawRequest" variable returns null even though a request

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
Community Hero

Re: Accessing data content using "RawRequest" variable returns null even though a request

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


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
lgermain315
Occasional Contributor

Re: Accessing data content using "RawRequest" variable returns null even though a request

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.

 

Olga_T
Moderator

Re: Accessing data content using "RawRequest" variable returns null even though a request

Hi,

 

Thank you all for participating. 

@lgermain315, it looks like you have found a solution. If so, could you please mark this topic as Solved? Other users will be able to find the solution easier if they face some similar situation.

 

Thanks in advance,

 


Olga Terentieva
SmartBear Assistant Community Manager

cancel
Showing results for 
Search instead for 
Did you mean: