Code example for DefaultHttpClient

Methods: getCredentialsProvidergetParamssetCookieStore

     * @param username	a username associated with an InSites login 
     * @param password	the password of the specified user 
     * @param port		the port number used to connect to the API service 
    public APIClient(URIScheme scheme, String host, String username, String password, int port) {
        client = new DefaultHttpClient();
        client.getParams().setParameter(ClientPNames.DEFAULT_HOST, new HttpHost(host, port,;
        HttpProtocolParams.setUserAgent(client.getParams(), "InSites Java Connection");
        client.setCookieStore(new BasicCookieStore());
        client.getCredentialsProvider().setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(username, password));
        authHeaderValue = "Basic " + Base64.encodeBase64String((username + ":" + password).getBytes());
     * Performs an HTTP GET request. 
     * Example: <code>get("/api/2.0/rest/equipment.xml?select=name");</code> 
     * @param uri	the path and query string portions of a resource URI 
     * @return		the GET response as a String