Skip to content

Instantly share code, notes, and snippets.

@saurav28
Last active January 31, 2022 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurav28/3f8e073946d7f3482ce1258264ec717c to your computer and use it in GitHub Desktop.
Save saurav28/3f8e073946d7f3482ce1258264ec717c to your computer and use it in GitHub Desktop.
Script to connect to SDM using CmisJS
//sample script to connect to SAP Document Managment using cmisjs
// https://github.com/agea/CmisJS
var cmis = require('cmis');
//Pre-requisite is to create a service instance of SDM and onboard a repository.
// SDM api endpoint will be provided in VCAP
var session = new cmis.CmisSession('<server url>');
//fetch the token progmatically using the UAA token endpoint
session.setToken('< access token>').loadRepositories()
.then(function(){
return session.query("select * from cmis:document", false)
})
.then(function(data) {console.log(data);
//change the default repository such that the subsequent APIs execute against the changed repository
var keys = Object.keys(session.repositories);
session.defaultRepository = session.repositories[keys[1]];
var result = session.query("select * from cmis:document", false);
result.then((data => console.log(data)))
})
.catch(err => console.log(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment