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:
parent
0a8115f42e
commit
93edea3720
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue