fix error handling infinite loop

The error Error() method of NewApiError was creating an infinite loop.
Also the error message could never be read since the body was already at EOF when entering error handling code.