Connection
Connection module is used to connect to kintone Rest API
This module execute requests using axios
Constructor
Parameter
Name | Type | Required | Description |
---|---|---|---|
domain | String | (condition) | Required for nodejs The domain that is able to authenticate on kintone app |
auth | Auth | (condition) | Required for nodejs The authentication object. |
guestSpaceID | Integer | (optional) | The guest space id. Use this parameter to connect to kintone guest space. |
Sample code
Init Connection module
Javascript
// Define Authentication object var kintoneAuth = new kintoneJSSDK.Auth(); var username = '{your_user_name}'; var password = '{your_password}'; kintoneAuth.setPasswordAuth(username, password); // Define connection that included auth var kintoneConnection = new kintoneJSSDK.Connection( kintoneAuth); // Define connection that included guest space var guestSpaceID = '{guest_Space_ID}'; var kintoneConnectionWithGuestSpaceDemo = new kintoneJSSDK.Connection(kintoneAuth, guestSpaceID); // Define connection without auth var guestSpaceID = '{guest_Space_ID}'; var kintoneConnectionWithGuestSpaceDemo = new kintoneJSSDK.Connection(null, guestSpaceID);
Nodejs
const kintone = require('@kintone/kintone-js-sdk'); // Define Authentication object let kintoneAuth = new kintone.Auth(); let username = '{your_user_name}'; let password = '{your_password}'; kintoneAuth.setPasswordAuth(username, password); let myDomainName = 'my.domain.tld'; let kintoneConnection = new kintone.Connection(myDomainName, kintoneAuth); // Define connection that included guest space let guestSpaceID = /*{guestSpaceID}*/; let kintoneConnectionWithGuestSpaceDemo = new kintone.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
Sample code
Set header of the Connection
Javascript
var key = '{your_header_key}'; var value = '{your_header_value}'; kintoneConnection.setHeader(key, value);
Nodejs
let key = '{your_header_key}'; let value = '{your_header_value}'; kintoneConnection.setHeader(key, value);
addRequestOption(key, value)
Add option that supported by axios option
Parameter
Name | Type | Required | Description |
---|---|---|---|
key | String | yes | The option's key name |
value | String | yes | The option's value of key |
Return
Sample code
Set header of the Connection
Javascript
var key = '{your_option_key}'; var value = '{your_option_value}'; kintoneConnection.addRequestOption(key, value);
Nodejs
let key = '{your_option_key}'; let value = '{your_option_value}'; kintoneConnection.addRequestOption(key, value);
setProxy(proxyHost, proxyPort, proxyUsername, proxyPassword)
Set proxy for the connection module.
This function is available on node.js environment only.
On Browser environment, proxy settings are controlled by the Browser.
Parameter
Name | Type | Required | Description |
---|---|---|---|
proxyHost | String | yes | The proxy host name |
proxyPort | String | yes | The proxy port number |
proxyUsername | String | optional | The username for proxy authentication. This parameter is required when proxy has authentication. |
proxyPassword | String | optional | The proxy port number. This parameter is required when proxy has authentication. |
Return
Sample code
Set proxy for the Connection
Nodejs
const proxyHost = '{your_proxy_host}'; const proxyPort = '{your_proxy_post}'; const proxyUsername = '{your_proxy_user}'; const proxyPassword = '{your_proxy_password}'; kintoneConnection.setProxy(proxyHost, proxyPort, proxyUsername, proxyPassword);
setHttpsProxy(proxyHost, proxyPort, proxyUsername, proxyPassword)
Set SSL-secured proxy for the connection module.
This function is available on node.js environment only.
On Browser environment, proxy settings are controlled by the Browser.
Parameter
Name | Type | Required | Description |
---|---|---|---|
proxyHost | String | yes | The proxy host name |
proxyPort | String | yes | The proxy port number |
proxyUsername | String | optional | The username for proxy authentication. This parameter is required when proxy has authentication. |
proxyPassword | String | optional | The proxy port number. This parameter is required when proxy has authentication. |
Return
Sample code
Set proxy for the Connection
Nodejs
const proxyHost = '{your_proxy_host}'; const proxyPort = '{your_proxy_post}'; const proxyUsername = '{your_proxy_user}'; const proxyPassword = '{your_proxy_password}'; kintoneConnection.setHttpsProxy(proxyHost, proxyPort, proxyUsername, proxyPassword);