Installation of the xECM NodeJS Package

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

Console

npm install xecm

Information

Install xECM NodeJS Package

NodeJS version 18 or higher
Use with Content Server Rest API
Requires: NodeJS and NPM is installed

Simple call using the xECM NodeJS Package

Get a node using xECM NodeJS Package.

NodeJS

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();

Information

Install xECM NodeJS Package

NodeJS 18 or higher
Use with Content Server Rest API
Requires: NodeJS and NPM is installed

Get List using the xECM NodeJS Package

Get subnodes using xECM NodeJS Package.

NodeJS

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 = 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<res["results"].length; i++) {
          let node = res["results"][i];
          console.log(node["properties"]["name"]);
        }
      }
      // prints out:
      // Employee Hans Meier
      // Employee Maria Bernasconi
      // Employee Max Mustermann
      // Employee Phil Egger
    } 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();

Information

Install xECM NodeJS Package

NodeJS 18 or higher
Use with Content Server Rest API
Requires: NodeJS and NPM is installed