I am the author of the xECM NodeJS Package and a certified xECM for SuccessFactors © consultant / developer / business administrator / analyst.
Check out our useful NodeJS examples that we collected in our OpenText © Extended ECM Content Server projects.
Install the xECM NodeJS Package to easily access Content Server API.
npm install xecm
Install 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();
Install 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'; // 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();
Install xECM NodeJS Package