I am using a service that only works with GZIP compression. I added the accept header and the service works, but RESTClient can not parse the content correctly.
My code:
def client = new RESTClient('https://rest-service-gziped.com')
def postBody = [ somekey: "somevalue" ]
def response = client.post(
path: "/some-endpoint",
body: postBody,
requestContentType : ContentType.JSON,
headers: ["Accept-Encoding": "gzip"]
)
The error message is
Mar 17, 2017 5:48:03 PM groovyx.net.http.RESTClient handleResponse
WARNING: Error parsing 'application/json; charset=utf-8' response
groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
Just add the following after RESTClient instantiation
client.setContentEncoding(ContentEncoding.Type.GZIP, ContentEncoding.Type.DEFLATE)