[APIClient] Better handling of request errors.

Fixes T361