Fix error reporting in api calls.