Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output the generated request and response from Groovy RestClient?

i am currently using the RestClient and cannot seem to figure out how to output the request xml and response xml for debugging and informational purpose...

I tried the solution mentioned here: http://agileice.blogspot.com/2009/09/pretty-printing-xml-results-returned.html

But that fails to work, any other suggestions?

like image 796
Marco Avatar asked Oct 22 '11 08:10

Marco


People also ask

How to get response in Groovy script?

Open groovy script > Right click > Get data > Select the test case step which has the API call > Select request/response etc.

How do you call REST API from Groovy?

Get the Places connection to execute the HTTP GET request on this resource and pass the text entered in the EmployeeAddress RTP as the value for the input query parameter. The Places connection object is a communication link between the Groovy script and the Google Places REST API resource.


1 Answers

The accepted answer (turn on wire logging using log4j) is basically correct, but I've had a fair bit of trouble turning on wire logging for HTTP builder in my Groovy script. For some reason, dropping a log4j.xml file in my $GROOVY_HOME/conf directory isn't working. Ultimately, I had to just add the appropriate logging options to the groovy command when I was running it.

groovy 
    -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog 
    -Dorg.apache.commons.logging.simplelog.showdatetime=true 
    -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG 
    myscript.groovy
like image 186
jonnybot Avatar answered Sep 28 '22 02:09

jonnybot