Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

parth123
New Contributor

build story in qliksense using engine api

Hi,

I am new to qlik sense.. I am trying to create a story by creating a custom function in mashup for a particular app

I have followed this link Create a story ‒ Qlik Sense

to create story ..but I am not able to create a story. What i am doing is trying to do this using websocket by opening a connection and then sending the json containing the create story params but I am receiving invalid request. from the server. I tried the same using the engine explorer and i am able to create the story there, but not able to create story through the code. I have tried everythingSmiley Frustratedee code

var storyData = {

        "handle": 1,

          "method": "CreateObject",

          "params": {

          "qProp": {

                    "qInfo": {

                    "qId": "story69",

                    "qType": "story"

               },

          "qExtendsId": "",

          "qMetaDef": {

               "title":"story 69",

               "description":"a story"

              }

       }

     }

}

var socket;

var host = "wss://xxx.com/app/"+ app.id + "?reloadUri=https://xxx.com/dev-hub/engine-api-explorer";

try{

var socket = new WebSocket(host);

console.log('Socket Status: '+ socket.readyState);

socket.onopen = function(){

console.log('Socket Status: '+socket.readyState+' (open)');

socket.send(storyData);

console.log('Sent: '+storyData);

}

socket.onmessage = function(msg){

console.log('Received: '+msg.data);

}

} catch(exception){

console.log('Error'+exception);

}

I am receving from server:

Socket Status: 0

bookmarkPoc.js:140 Socket Status: 1 (open)   bookmarkPoc.js:142
Sent: [object Object]  
bookmarkPoc.js:145

Received: {"jsonrpc":"2.0","method":"OnAuthenticationInformation","params":{"userId":"abc","userDirectory":"xyz","logoutUri":"https://xxx.com/qps/user","mustAuthenticate":false}}

bookmarkPoc.js:145
Received: {"jsonrpc":"2.0","id":0,"error":{"code":-32600,"parameter":"Request processing error","message":"Invalid Request"}}

Why i am recieving Invalid Request as when i do the same in engine explorer I am able to create a story.

Please any help is much appreciated.

Thanks

Tags (2)
1 Solution

Accepted Solutions
Employee
Employee

Re: build story in qliksense using engine api

Hi Kumar,

I created a Chrome extension a while back to create stories and slides with embedded snapshots. I used qSocks since it makes communicating with the engine much easier. Here is the code I used for creating a new story:

          var storyProp = {
               "qInfo": {
                    "qId": "story01",
                    "qType": "story"
               },
               "qMetaDef": {
                    "title": "Session: " + datestr,
                    "description": "Some description"
               },
               "rank": 0,
               "thumbnail": {
                    "qStaticContentUrlDef": {}
               },
               "qChildListDef": {
                    "qData": {
                         "title": "/title",
                         "rank":"/rank"
                         // "description": "/description",
                         // "children": "/qChildListDef"
                    }
               }
          };

          return new Promise(function(resolve, reject) {
               handle.createObject(storyProp).then(function(story) {
                    handles.curStory = story;
                    console.log("Story created",story);
                    return resolve(story);
               }, function(error) {
                    return reject(error);
               })
          });

I hope this helps.

Cheers,

Todd

2 Replies
Employee
Employee

Re: build story in qliksense using engine api

Hi Kumar,

I created a Chrome extension a while back to create stories and slides with embedded snapshots. I used qSocks since it makes communicating with the engine much easier. Here is the code I used for creating a new story:

          var storyProp = {
               "qInfo": {
                    "qId": "story01",
                    "qType": "story"
               },
               "qMetaDef": {
                    "title": "Session: " + datestr,
                    "description": "Some description"
               },
               "rank": 0,
               "thumbnail": {
                    "qStaticContentUrlDef": {}
               },
               "qChildListDef": {
                    "qData": {
                         "title": "/title",
                         "rank":"/rank"
                         // "description": "/description",
                         // "children": "/qChildListDef"
                    }
               }
          };

          return new Promise(function(resolve, reject) {
               handle.createObject(storyProp).then(function(story) {
                    handles.curStory = story;
                    console.log("Story created",story);
                    return resolve(story);
               }, function(error) {
                    return reject(error);
               })
          });

I hope this helps.

Cheers,

Todd

parth123
New Contributor

Re: build story in qliksense using engine api

Hi Todd,

Thanks a lot. I was able to implement this in my mashup using qsocks library.  Worked like a charm

Community Browser