Added checking if response is empty and return in api request.
Added more curl options in api request.
Improved handling of curl connection errors in api request.