Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bekahbeets
Creator
Creator

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
Aiham_Azmeh
Employee
Employee

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

bekahbeets
Creator
Creator
Author

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.

Aiham_Azmeh
Employee
Employee

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


bekahbeets
Creator
Creator
Author

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.

Aiham_Azmeh
Employee
Employee

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

bekahbeets
Creator
Creator
Author

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.

Aiham_Azmeh
Employee
Employee

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

bekahbeets
Creator
Creator
Author

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.

Aiham_Azmeh
Employee
Employee

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,