Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

bekahbeets2003
Contributor

Json commands from engine api explorer does not return list of sheets

So I can connect to the qlik server via javascript fine.. i get the engine and select an app via the code generated by the engine api explorer fine. When i get the code from the engine api explorer to list the sheets and pop it into the javascript, I get a list of the apps, not the sheets...

this:

[

{

"name": "SHEETLIST",

"method": "CreateSessionObject",

"handle": "${dochandle}",

"params": [

{

"qInfo": {

"qType": "SheetList"

},

"qAppObjectListDef": {

"qType": "sheet",

"qData": {

"title": "/qMetaDef/title",

"description": "/qMetaDef/description",

"thumbnail": "/thumbnail",

"cells": "/cells",

"rank": "/rank",

"columns": "/columns",

"rows": "/rows"

}

}

}

]

},

{

"method": "GetLayout",

"handle": "${SHEETLIST.result.qReturn.qHandle}",

"params": []

}

]

Does not give a list of sheets - it gives the list of apps/docs. In the Engine API explorer it does, but not in javascript.

10 Replies
Employee
Employee

Re: Json commands from engine api explorer does not return list of sheets

Hi bekahbeets2003‌,

I am not entirely sure I understand your issue. Creating a sessionObject like with the Engine API explorer's macro, after `getLayout` should result in an object similar to this below example:

{

    "jsonrpc": "2.0",

    "id": 4,

    "result": {

          "qLayout": {

              "qInfo": {

                    "qId": "317c3d47-7b0e-47ab-8cdb-2a247c7d4e2e",

                    "qType": "SheetList"

                  },

              "qSelectionInfo": {},

              "qAppObjectList": {

                    "qItems": [{

                        "qInfo": {

                              "qId": "kHgmg",

                              "qType": "sheet"

                          },

                        "qMeta": {...}                           

"qAppObjectList" will contain a "qItems" array with "sheet" objects ("qType": "sheet")

Can you share you JS snippet? Are you getting the layout of the app instead of the newly created sessionObject?

Br

bekahbeets2003
Contributor

Re: Json commands from engine api explorer does not return list of sheets

In the engine api explorer, it returns that, but when i put the request code (generated in engine api explorer List Sheets macro) into javascript on my aspx page, it gives the docs/apps, not the sheet list.

Highlighted
Employee
Employee

Re: Json commands from engine api explorer does not return list of sheets

Alright, then my guess will be about right,

Tthe first call have "handle": "${dochandle}" while the second should be "handle": ${SHEETLIST.result.qReturn.qHandle}"


1- createSessionObject -- use the Doc handle

2- getLayout -- use the returned sessionObject handle (you are probably getting the app layout instead of the newly sessionObject layout)


I hope this helps


bekahbeets2003
Contributor

Re: Json commands from engine api explorer does not return list of sheets

I'm a bit confused because in the code i listed above, the createSessionObject uses the dochandle and the getlayout uses the qhandle like you just said it should and it does not return sheets.

Employee
Employee

Re: Json commands from engine api explorer does not return list of sheets

qHandle.PNG

From the printscreen, you can see that the "createSessionObject" call uses qHandle 1, the returned GenericObject has qHandle 2 => the one you should use when calling getLayout

bekahbeets2003
Contributor

Re: Json commands from engine api explorer does not return list of sheets

Does. Not. Work. And you're supposed to embed the request code that is on the top right in the engine explorer. The bottom is what is auto generated.

Employee
Employee

Re: Json commands from engine api explorer does not return list of sheets

Maybe sharing your javascript codesnippet will help me trying to help you

bekahbeets2003
Contributor

Re: Json commands from engine api explorer does not return list of sheets

My javascript is exactly what is above. i didn't change it. i copied and pasted. its just a bug in qlik when you send the json over.

Employee
Employee

Re: Json commands from engine api explorer does not return list of sheets

The json struct is an array of 2 calls to the engine that should be translated in javascript to something like this:

app.createSessionObject(/*here the code is using qHandle 1*/).then(function(responseFromEngine){

     var handle = responseFromEngine.qHandle;

     app.getSessionObjectLayout(/*code should use the handle from the engine response*/).then(function(sheetList){

          console.log(sheetList)

     })

})

In Engine API explorer we are magically modifying the code so it replaces ${SHEETLIST.result.qReturn.qHandle} with the handle from the first engine call. My guess is that your code is reusing the same handle for the app, so in conclusion you are making a GetLayout on the App and not on the newly created SessionObject.


I really hope this helps,