Auto select http or https connection to API server