Docs‎ > ‎CA Live API Creator‎ > ‎Create‎ > ‎Resources‎ > ‎REST APIs‎ > ‎

Connecting through a proxy

If you have difficulties connecting to your REST API from your programming environment, but the API Creator is working as expected, the most likely explanation is that your browser is using a proxy to connect to the web. This is common in large organizations, and is typically used to filter web traffic for security reasons.

If this is the case, look at your browser settings and determine the address and port number of your proxy server.

Once you have this information, setting up your program to use the proxy depends entirely on your programming platform.

Java

In Java, failure to connect will show as an exception similar to the following:

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to http://servername.espressologic.com refused
       at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127)
       at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)
       at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:101)
       at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:381)
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
       at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)

Using a proxy can be done by simply setting two system properties:

System.setProperty("http.proxyHost", "proxyname");  // Enter your proxy name here
System.setPropery("http.proxyPort", "8080");

Some proxies require authentication. In that case, you will also need to add this:

Authenticator authenticator = new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
        return (new PasswordAuthentication("user", "password".toCharArray()));
    }
};
Authenticator.setDefault(authenticator);

JavaScript

JavaScript in the browser will of course use the browser's proxy settings, and therefore should never be a problem.

Server-side JavaScript (e.g. Node.js) can use a proxy by simply routing all traffic through the proxy, e.g.:

var http = require('http');
var google = http.createClient(3128, 'your.proxy.host');
var request = google.request('GET', '/',
  {'host': 'www.google.com'});
request.end();


Other languages have different conventions, which also depend on which framework(s) and libraries you may be using.