Skip to content

Connection

Connection module will used as a connector to connect to kintone Rest API

Constructor

Parameter

Name Type Required Description
domain String yes The Domain name or FQDN
auth Auth yes The authentication object
guestSpaceID Integer (optional) The guest space id. Use this parameter to connect to kintone guest space.

Sample code

Init Connection module Source code

// Define Authentication object
Auth kintoneAuth = new Auth();
String username = "cybozu";
String password = "cybozu";
kintoneAuth.setPasswordAuth(username, password);

String myDomainName = "sample.cybozu.com";
Connection connection = new Connection(myDomainName, kintoneAuth);


// Define connection that included guest space
int guestSpaceID = 1;
Connection kintoneConnectionWithGuestSpaceDemo =
    new Connection(myDomainName, kintoneAuth, guestSpaceID);

Methods

setHeader(key, value)

Set new header of the Connection

Parameter

Name Type Required Description
key String yes The header's key name
value String yes The header's value of key

Return

Connection

Sample code

Set header of the Connection Source code
String username = "cybozu";
String password = "cybozu";
String key = "X-HTTP-Method-Override";
String value = "GET";

// Init authenticationAuth
Auth kintoneAuth = new Auth();
kintoneAuth.setPasswordAuth(username, password);

String myDomainName = "sample.cybozu.com";
Connection connection = new Connection(myDomainName, kintoneAuth);
connection.setHeader(key, value);

setProxy(host, port, username, password)

Set the proxy of the request

Parameter

Name Type Required Description
host String yes The proxy host name
port Integer yes The proxy port number
username String (optional) User name of the proxy
password String (optional) Password of the proxy

Return

Connection

Source code

Set the proxy of the request Source code
String username = "cybozu";
String password = "cybozu";
String proxyHost = "xxxx";
Integer proxyPort = 1234;

// Init authenticationAuth
Auth kintoneAuth = new Auth();
kintoneAuth.setPasswordAuth(username, password);

String myDomainName = "sample.cybozu.com";
Connection connection = new Connection(myDomainName, kintoneAuth);

// Set proxy without proxyUsername & proxyPassword
connection.setProxy(proxyHost, proxyPort);

// Set proxy with proxyUsername & proxyPassword
String proxyUsername = "xxxx";
String proxyPassword = "xxxx";
connection.setProxy(proxyHost, proxyPort, proxyUsername, proxyPassword);

setHttpsProxy(host, port, username, password)

Set the SSL-secured proxy of the request

Parameter

Name Type Required Description
host String yes The proxy host name
port Integer yes The proxy port number
username String (optional) User name of the proxy
password String (optional) Password of the proxy

Return

Connection

Source code

Set the proxy of the request Source code
String username = "cybozu";
String password = "cybozu";
String proxyHost = "xxxx";
Integer proxyPort = 1234;

// Init authenticationAuth
Auth kintoneAuth = new Auth();
kintoneAuth.setPasswordAuth(username, password);

String myDomainName = "sample.cybozu.com";
Connection connection = new Connection(myDomainName, kintoneAuth);

// Set ssl-secured proxy without proxyUsername & proxyPassword
connection.setHttpsProxy(proxyHost, proxyPort);

// Set ssl-secured proxy with proxyUsername & proxyPassword
String proxyUsername = "xxxx";
String proxyPassword = "xxxx";
connection.setHttpsProxy(proxyHost, proxyPort, proxyUsername, proxyPassword);