Skip to content

Connection

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

This module excute the request process by axios npm.

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

Connection

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

Connection

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)

Set the proxy for the axios option

Parameter

Name Type Required Description
proxyHost String yes The proxy host name
proxyPort String yes The proxy port number

Return

Connection

Sample code

Set proxy for the Connection

Javascript


    var proxyHost = '{your_proxy_host}';
    var proxyPort = '{your_proxy_post}';
    kintoneConnection.setProxy(proxyHost, proxyPort);

Nodejs


    const proxyHost = '{your_proxy_host}';
    const proxyPort = '{your_proxy_post}';
    kintoneConnection.setProxy(proxyHost, proxyPort);