Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Engine API response handling in java script

Hi,

I am pretty new to qliksense as well as java script. Based on some tutorials I was able to establish connection between my web app and qliksense.

I couldn't understand how to read the response in java script.

when I print the response, i am getting it like json object. But i could not print or use the detailed values by using dot qualifier as we normally do for JSON.

Response:

=========

> console.log(data)

{

  "jsonrpc": "2.0",

  "id": 1,

  "result": {

    "qDocList": [

      {

        "qDocName": "Accounts Payable.qvf",

        "qConnectedUsers": 0,

        "qFileTime": 42970.94695601852,

        "qFileSize": 2883584,

        "qDocId": "C:\\Users\\Karthik\\Documents\\Qlik\\Sense\\Apps\\Accounts Payable.qvf",

        "qMeta": {

          "description": "",

          "dynamicColor": ""

        },

        "qLastReloadTime": "2017-08-23T16:36:56.600Z",

        "qTitle": "accounts payable",

        "qThumbnail": {},

        "key": "C:\\Users\\Karthik\\Documents\\Qlik\\Sense\\Apps\\Accounts Payable.qvf",

        "$$hashKey": "object:107"

      },

      {

        "qDocName": "Consumer Sales.qvf",

        "qConnectedUsers": 0,

        "qFileTime": 42962.543217592596,

        "qFileSize": 10485760,

        "qDocId": "C:\\Users\\Karthik\\Documents\\Qlik\\Sense\\Apps\\Consumer Sales.qvf",

        "qMeta": {

But when i try to print data.qDocList or data.result.qDocList , i am getting as undefined.


Thanks in advance

4 Replies
Francis_Kabinoff
Former Employee
Former Employee

I think you need to use JSON.parse like data = JSON.parse(data); and then you should have an object.

So it looks like you're just making JSON-RPC requests to the engine. You should check out GitHub - qlik-oss/enigma.js: JavaScript library for consuming Qlik's QIX Engine.

Anonymous
Not applicable
Author

Hi Francis,

Thanks for the response. I even tried out parsing, still it's not working.

here is the code,

ws.onmessage = function (event) {

  // console.log(event.data);

  var msg = JSON.parse(event.data);

  console.log(event.data);

  console.log(msg.result);

}

Prints are working fine with the DOT qualifier till the level result but not beyond that.

all that I need is qDocName .


Thanks & Regards,

Kiriti

ErikWetterberg

Hi,

Sounds strange. So you mean thet something like:

console.log(msg.result.qDocList)

does not work?

The docname should be at something like msg.result.qDocList[0].qDocName for the first document in the list.

What browser are you using??

Erik Wetterberg

Anonymous
Not applicable
Author

Hi Eirk,

msg.result.qDocList[0] is also not working. I am using chrome.