← Zurück zur Übersicht

xECM NodeJS Package

Quickly access Content Server API using NodeJS.

I am the author of the xECM NodeJS Package and a certified xECM for SuccessFactors © consultant / developer.

Installation

Install the xECM NodeJS Package to easily access Content Server API.

npm install xecm

Simple call using the xECM NodeJS Package

Get a node using xECM NodeJS Package.

const xecm = require('xecm');

async function mainProg() {
    let cshost = 'http://otcs.phil.local';
    let cspath = '/otcs/cs.exe';
    // get OTCSTicket with username and password
    let csapi = new xecm.CSRestAPI(xecm.LoginType.OTCS_TICKET, `${cshost}${cspath}`, 'myuser', 's#cret', true, xecm.LogType.INFO);
    // use xecm.LogType.ERROR to reduce logging
    await csapi.doLogin();

    let nodeId = 182771;
    try {
        let res = await csapi.node_get(`${cshost}${cspath}`, nodeId, ['id', 'name', 'type', 'type_name'], false, false, false);
        console.log(res);
        // {
        // 'properties': {'id': 130480, 'name': 'Bewerbung-Phil-Egger-2020.pdf', 'type': 144, 'type_name': 'Document'},
        // 'categories': [],
        // 'permissions': {'owner': {}, 'group': {}, 'public': {}, 'custom': []},
        // 'classifications': []
        // }
    } catch(innerErr) {
        if (innerErr instanceof xecm.LoginTimeoutException) {
            console.error(`Ticket has been invalidated since last login (timeout) - do a re-login: ${innerErr}`)
        } else {
            console.error(`General Error: ${innerErr}`)
        }
    }
}
// run main program
mainProg();

Get List using the xECM NodeJS Package

Get subnodes using xECM NodeJS Package.

const xecm = require('xecm');

async function mainProg() {
    let cshost = 'http://otcs.phil.local';
    let cspath = '/otcs/cs.exe';
    
    let csapi = new xecm.CSRestAPI(xecm.LoginType.OTCS_TICKET, `${cshost}${cspath}`, 'myuser', 's#cret', true, xecm.LogType.INFO);
    await csapi.doLogin();

    let nodeId = 30648;
    try {
        let res = await csapi.subnodes_get(`${cshost}${cspath}`, nodeId, ['id', 'name'], false, false, false, 1);
        if (res && res["results"]) {
            for(let i=0; i