Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

justin_morley
Contributor

Accessing Engine API in Qlik Sense Desktop from Node.js

Hi,

I have a Node.js solution which I've developed which uses the Engine API, wrapped by the marvellous Enigma.js, connecting to a QAP server instance to build and delete new apps on the fly according to given criteria.

It's all working beautifully in this environment.

Today I tried to port this to my laptop so I could 1) Develop on the move and 2) Show off the rather exciting possibilities such a solution offers. However I hit snags around authentication. My laptop has Desktop on it, not any of the Server versions.

Is it actually possible to do this - Node.js talking to Qlik Sense Desktop - or is this restricted? The configuration I pass to Enigma is included below. What needs to be different to connect to Qlik Sense Desktop?

{

  schema: qixSchema,

  session: {

      unsecure: false,

      host: qConfig.hostName,

      port: qConfig.QlikServicePort

    },

    createSocket: (url) => {

      return new WebSocket(url, {

        origin: qConfig.hostPrefix + qConfig.hostName,

        cert: fs.readFileSync(qConfig.certDir + qConfig.certPem),

        key: fs.readFileSync(qConfig.certDir + qConfig.keyPem),

        headers: {

          'X-Qlik-User': qConfig.header + qConfig.QlikServiceDirectory + qConfig.middle + qConfig.QlikServiceUser

        },

        rejectUnauthorized: false

      });

  }

2 Replies
websy1985
New Contributor III

Re: Accessing Engine API in Qlik Sense Desktop from Node.js

Hi Justin,

Connecting to Qlik Sense Desktop should be fairly straight forward, you just need to change your config to something like this:

config: {
  unsecure: true, 
  host: "localhost",
  port: 4848
}

You also don't need the certs in your connection as Desktop doesn't require any authentication and, lastly, your node server needs to be running on localhost as Sense Desktop won't accept connections from anywhere else. Given your description above I imagine that that's the case anyway.

In theory that should be it.

I hope that helps.

justin_morley
Contributor

Re: Accessing Engine API in Qlik Sense Desktop from Node.js

Hi Nick,

Thanks for your reply.

Because I'm running Enigma from Node.js and not a browser, it crashes with this:

TypeError: this.createSocket is not a function

    at RPC.open (C:\temp\QAPService\QAPService\node_modules\enigma.js\dist\enig

a.js:2372:29)

What should my createSocket function look like?

Thanks