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,10 +477,12 @@ func (c apiClient) Do(ctx context.Context, req *http.Request) (*http.Response, [
var result apiResponse
if err = json.Unmarshal(body, &result); err != nil {
return resp, body, &Error{
Type: ErrBadResponse,
Msg: err.Error(),
if http.StatusNoContent != code {
if err = json.Unmarshal(body, &result); err != nil {
return resp, body, &Error{
Type: ErrBadResponse,
Msg: err.Error(),
}
}
}