For some reason when I uncomment the line //restApi.setProxy(new URI("http://myproxy.mycompany.com"), "MyProxyUsername", "MyProxyPassword");
with correct inputs, the error goes off. For all those who need the inputs, please put in the following:
restApi.setProxy(new URI("http://rally1.rallydev.com"), "xyz@abc.com", "rallypassword");
so the working code is as below:
import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; import com.rallydev.rest.RallyRestApi; import com.rallydev.rest.client.HttpClient; import com.rallydev.rest.request.GetRequest; import com.rallydev.rest.response.GetResponse; public class ConnnectionTestWithHTTPClient { public static void main(String[] args) throws URISyntaxException, IOException { String host = "https://rally1.rallydev.com"; String apiKey = "_apikey"; String applicationName = "Connnection Test With HTTPClient"; RallyRestApi restApi = new RallyRestApi(new URI(host),apiKey); restApi.setApplicationName(applicationName); restApi.setProxy(new URI("http://rally1.rallydev.com"), "abc@abc.com", "rallypassword"); //YOUR PROXY SETTINGS HERE HttpClient client = restApi.getClient(); try { SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() { public boolean isTrusted(X509Certificate[] certificate, String authType) throws CertificateException { //trust all certs return true; } }, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, sf)); String workspaceRef = "/workspace/1234"; GetRequest getRequest = new GetRequest(workspaceRef); GetResponse getResponse = restApi.get(getRequest); System.out.println(getResponse.getObject()); } catch (Exception e) { System.out.println(e); } finally { restApi.close(); } } }