Skip to content

Instantly share code, notes, and snippets.

@saurav28
Last active January 31, 2022 09:32
Show Gist options
  • Select an option

  • Save saurav28/3f8e073946d7f3482ce1258264ec717c to your computer and use it in GitHub Desktop.

Select an option

Save saurav28/3f8e073946d7f3482ce1258264ec717c to your computer and use it in GitHub Desktop.

Revisions

  1. @saurav-sarkar-1 saurav-sarkar-1 renamed this gist Jan 7, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @saurav-sarkar-1 saurav-sarkar-1 created this gist Jan 7, 2021.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    //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));