2017-03-17 11 views
0

GZIP圧縮でのみ動作するサービスを使用しています。 Acceptヘッダとサービスが追加されましたが、RESTClientはコンテンツを正しく解析できません。RESTClientを使用してGZIP応答を受信する方法

マイコード:

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"] 
) 

エラーメッセージが

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 

答えて

0

だけRESTClientのインスタンス化

client.setContentEncoding(ContentEncoding.Type.GZIP, ContentEncoding.Type.DEFLATE)

後に以下を追加しています
関連する問題