diff --git a/pkg/client.go b/pkg/client.go index 9d52cf7..f4cc188 100644 --- a/pkg/client.go +++ b/pkg/client.go @@ -10,7 +10,6 @@ import ( "net/http" "net/http/httputil" "os" - "strings" "text/template" "time" ) @@ -243,13 +242,11 @@ func (c *Client) MakeAPICall(verb string, r *Response, data []byte) error { return fmt.Errorf("reading response body: %v", err) } resp.Body.Close() - respString := string(respBytes) - resp.Body = ioutil.NopCloser(strings.NewReader(respString)) if resp.StatusCode != http.StatusOK { - return fmt.Errorf("unexpected response status %d: %q", resp.StatusCode, respString) + return fmt.Errorf("unexpected response status %d: %q", resp.StatusCode, respBytes) } - if err = json.NewDecoder(resp.Body).Decode(&r); err != nil { - return fmt.Errorf("decoding error for %q: %v", respString, err) + if err = json.Unmarshal(respBytes, &r); err != nil { + return fmt.Errorf("decoding error for %q: %v", respBytes, err) } if r.Stat != "ok" { e, _ := json.MarshalIndent(r.Error, "", " ")