From c62bc32df593a1d42a73586fc984dc826bf098b6 Mon Sep 17 00:00:00 2001 From: Dmitry Ukov Date: Sat, 16 Nov 2019 11:42:08 -0600 Subject: [PATCH] Do not return error in case of empty body Change-Id: Ie7a049537e4be0ca00ff7ceb3bc5afffe73823e8 --- client/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index 44070c0..f590550 100644 --- a/client/client.go +++ b/client/client.go @@ -154,7 +154,6 @@ func parameterToJson(obj interface{}) (string, error) { return string(jsonBuf), err } - // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) @@ -329,6 +328,9 @@ func (c *APIClient) prepareRequest( } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } if s, ok := v.(*string); ok { *s = string(b) return nil