Replace UnauthorizedException with ApiException