Added more exception handling to api url discovery