← Zurück zur Übersicht

xECM Python Module

Python Module to interact with the OpenText © xECM Content Server REST API.

I am the author of the xECM Python Module.

Installation

Install the xECM Python Module to easily access Content Server API.

pip install xecm

Simple call using the xECM Python Module

Get a node using xECM Python Module.

import xecm
import logging

# use logging.ERROR to only log ERRORS - reduce logging
logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO)

if __name__ == '__main__':
    deflogger = logging.getLogger("mylogger")
    cshost = 'http://otcs.phil.local'
    
    # get OTCSTicket with username and password
    csapi = xecm.CSRestAPI(xecm.LoginType.OTCS_TICKET, f'{cshost}/otcs/cs.exe', 'myuser', 's#cret', True, deflogger)
    
    # Get Enterprise Node
    nodeId = 2000
    res = csapi.node_get(f'{cshost}/otcs/cs.exe', nodeId, ['id', 'name'], False, False, False)
    print(res)
    # {
    # 'properties': {'id': 2000, 'name': 'Enterprise'},
    # 'categories': [],
    # 'permissions': {'owner': {}, 'group': {}, 'public': {}, 'custom': []},
    # 'classifications': []
    # }

Get List using the xECM Python Module

Get subnodes using xECM Python Module.

import xecm
import logging

if __name__ == '__main__':
    deflogger = logging.getLogger("mylogger")
    cshost = 'http://otcs.phil.local'
    csapi = xecm.CSRestAPI(xecm.LoginType.OTCS_TICKET, f'{cshost}/otcs/cs.exe', 'myuser', 's#cret', True, deflogger)
    
    # Get Business Workspace Main Folder
    nodeId = 30648
    res = csapi.subnodes_get(f'{cshost}/otcs/cs.exe', nodeId, ['id', 'name'], False, False, False, 1)
    
    if res and res.get('results', []):
        for node in res['results']:
            print(node['properties']['name'])
            # prints out:
            # Employee Hans Meier
            # Employee Maria Bernasconi
            # Employee Max Mustermann
            # Employee Phil Egger