The REST service I want to consume answers as a gzipped encoded JSON. It provides the Content-Encoding: gzip, but my OkHttp does not encode it to readable text,
Replace this:
@Headers({
"Accept-Encoding: gzip, deflate",
"Content-Type: application/json;charset=utf-8",
"Accept: application/json"
})
With this:
@Headers({
"Content-Type: application/json;charset=utf-8",
"Accept: application/json"
})
When you provide your own Accept-Encoding header you’re instructing OkHttp that you want to do your own decompression. By omitting it, OkHttp will take care of both adding the header and the decompression.