Multiple cui.js Objects

Typically, an App instantiates one cui.js object and uses it for every API call. This is suitable when all the APIs share a common server URL, and a single mode of authentication. However, if limitations arise, an App can use multiple cui.js objects simultaneously.


Generally, the following scenarios require the use of multiple cui.js objects:

  • An App that simultaneously calls Covisint APIs running on different servers.
  • An App that simultaneously calls Covisint and 3rd-party APIs.
  • An App that simultaneously depends on different types of Authentication.
  • Any combination of the above.

Defining Multiple objects

Each object needs a unique sessionId when it is created, and a unique reference in the App. In that way, the context of each object is distinct.

In this example, one object targets the STG environment, and another targets a 3rd-party environment.

var firstCuiJs = {};
var secondCuiJs = {};
var thirdPartyCallDefs = [{...}];

    sessionId: 1,
    serviceUrl: 'STG',
    defs: [''],
}).then(function(obj) {
    firstCuiJs = obj;

    sessionId: 2,
    serviceUrl: '',
    defs: [thirdPartyCallDefs],
}).then(function(obj) {
    secondCuiJs = obj;

Then, the objects can be used as simultaneously, as desired. In this somewhat contrived example, one of the object’s is used for authentication and a second object is used to make an API call.

    clientId: 'YOUR CLIENT ID',
    clientSecret: 'YOUR CLIENT SECRET'
}).then(function() {
    secondCuiJs.getThirdPartySubjects().then(function(response) {
        // do something with response...