Do not parse json on 204 responses (#476)

* Do not return BadResponse for no content 

Signed-off-by: Adam Jaso <2285656+adamjaso@users.noreply.github.com>
This commit is contained in:
Adam Jaso 2018-10-10 07:20:17 -07:00 committed by Krasi Georgiev
parent 0a8115f42e
commit 93edea3720
1 changed files with 6 additions and 4 deletions

View File

@ -477,12 +477,14 @@ func (c apiClient) Do(ctx context.Context, req *http.Request) (*http.Response, [
var result apiResponse var result apiResponse
if http.StatusNoContent != code {
if err = json.Unmarshal(body, &result); err != nil { if err = json.Unmarshal(body, &result); err != nil {
return resp, body, &Error{ return resp, body, &Error{
Type: ErrBadResponse, Type: ErrBadResponse,
Msg: err.Error(), Msg: err.Error(),
} }
} }
}
if apiError(code) != (result.Status == "error") { if apiError(code) != (result.Status == "error") {
err = &Error{ err = &Error{