I am new to groovy and started using it to test some REST services. I had a problem parsing my XML response from our service because Content is not allowed in the prolog. After some searching, I came across a message saying that in the beginning there might be a byte order marker. To compensate, I followed their approach to crop characters before the first <and then parse the answer. Although this works, I was also told that the problem is that the response is returned as "Transfer-Encoding: chunked".
Using HTTPBuilder, is there a way to handle response replies without trimming characters? If I try:
def http = new HTTPBuilder('url')
http.request( Method.valueOf("GET"), XML )
I get the message "Invalid content in prolog message." However:
http.request( Method.valueOf("GET"), TEXT )
It works, but requires trimming the text until the first <before sending the response to XmlParser.
source
share