AllegiantAir / g4js-cognos

Node.js client for Cognos application integration utilizing CMS.
MIT License
5 stars 9 forks source link

How do I know I am passing something wrong to the service? #9

Closed xumes closed 6 years ago

xumes commented 6 years ago

Hello,

I am trying to connect to an instance of Cognos, but I am not sure if we have the CMS available. The app is not returning error, so I am not sure what could be wrong.

My code looks like this:

const Cms = require('g4js-cognos').Cms;

let config = {
    serviceUrl: 'https://zcogwass1.boulder.ibm.com/transform/cognitive/bi',
    serviceNamespace: 'IBMIntranet',
    serviceUsername: 'rmsantos@br.ibm.com',
    servicePassword: '(password here)'
}
let report = new Cms(config.serviceUrl, config.serviceNamespace, config.serviceUsername, config.servicePassword);

console.log('logging on...');
console.log(report);

report.logon().then(function (response) {
    console.log('Uhuuu...');
    console.log(response.statusCode, response.body);

    let qs = {
        p_prm1: 1,
        p_prm2: '2007-05-02',
        p_prm3: '2009-08-09',
        fmt: 'HTMLFragment'
    };

    console.log('getting report...');

    report.getReportById(reportId, qs).then(function (response) {
        console.log(response.statusCode, response.body);
    });

});
console.log('finishing...');

I have only these logs on my console:

logging on...
Cms {
  serviceUrl: 'https://zcogwass1.boulder.ibm.com/transform/cognitive/bi',
  namespace: 'IBMIntranet',
  username: 'rmsantos@br.ibm.com',
  password: 'password here' }
finishing...

Can you help me?

helloanoop commented 6 years ago

report.logon() returns a promise.

You can catch the error by doing

report
  .logon()
  .then(function(response){
     // do something
  })
  .catch(function(error){
     // handle error
  });

Hope this helps!

xumes commented 6 years ago

great, this is obviously, sorry, didn't catch this before.

I am making progress, do you know what kind of error is that?

error found: { Error: self signed certificate in certificate chain
    at TLSSocket.<anonymous> (_tls_wrap.js:1103:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:637:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
xumes commented 6 years ago

fixed. thank you!