Change the post map to include the contentType
to force plain-text parsing (and, I believe change to Accepts
header) as below:
http.post( path: 'pathToMyApp',
requestContentType: "text/xml",
contentType: "text/xml") { resp, reader ->
Alternatively, you can change parser for this and future requests by adding a ParserRegistry
remap after the constructor:
http.parser.'text/html' = http.parser.'text/plain'
You can also add a call to setContentType()
, after your constructor call for HTTPBuilder
:
//...
def http = new HTTPBuilder(url); //existing code
http.contentType = ContentType.TEXT //new addition
http.post( path: 'pathToMyApp', //existing code
//...