fixed bug in ApiClient class in the way params are posted to REST services, handling errors so the error content is returned instead of an exception, some refactoring