handle json error when status code is 2xx

The http-client based version.