Unable to get json response: MalformedJsonException

As a workaround, you can do something like this to decompress the GZIP body:

from java.lang import String
from java.io import ByteArrayInputStream, ByteArrayOutputStream
from java.util.zip import GZIPInputStream

client = system.net.httpClient()

response = client.get("https://httpbin.org/gzip")

encoding = "UTF-8"
gzip = GZIPInputStream(ByteArrayInputStream(response.body))
bytesOut = ByteArrayOutputStream()
gzip.transferTo(bytesOut)
decoded = bytesOut.toByteArray()

print String(decoded, encoding) 
2 Likes