Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to learn how to pull data from the Qlik-Sense APi (I'm using just the desktop client, no server).
I've created the WebSocket and a variable myOpenDocObj to hold my OpenDoc Method.
How do I actually send this OpenDoc message to the API and then how do I get back a response ?
Any help appreciated (I know this must be very basic stuff for most people on here!)
<!DOCTYPE html> <html> <body> <h2>This is a test.</h2> <p id="demo"></p> <script> var ws = new WebSocket("ws://localhost:4848/app/"); var myOpenDocObj = { "method": "OpenDoc", "handle": -1, "params": [ "C:\\Users\\Simon\\Documents\\Qlik\\Sense\\Apps\\Consumer Sales.qvf" ], "outKey": -1, "id": 2 }; </script> </body> </html>
Hi,
ws.send(message) is the method to use. Check the specification here:
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
To handle the reply you need an eventlistener for the message event. An example is on the same page.
Thanks. I've made some progress now (I'm sending and receiving a response). However I'm getting an 'invalid request'.
Do you have any idea what I could be doing wrong?
(Thanks again)
Message from server {"jsonrpc":"2.0","method":"OnConnected","params":{"qSessionState":"SESSION_CREATED"}}
(index):37
Message from server {"jsonrpc":"2.0","id":0,"error":{"code":-32600,"parameter":"Request processing error","message":"Invalid Request"}}
<!DOCTYPE html> <html> <body> <h2>This is a test.</h2> <p id="demo"></p> <script> var myOpenDocObj = { "method": "OpenDoc", "handle": -1, "params": [ "C:\\Users\\Simon\\Documents\\Qlik\\Sense\\Apps\\Consumer Sales.qvf" ], "outKey": -1, "id": 2 } // Create WebSocket connection. const socket = new WebSocket('ws://localhost:4848/app/'); // Connection opened socket.addEventListener('open', function (event) { socket.send(myOpenDocObj); }); // Listen for messages socket.addEventListener('message', function (event) { console.log('Message from server ', event.data); }); </script> </body> </html>
Hi,
You probably need to include
jsonrpc: "2.0"
and I don't know about the outkey.
Didn't help unfortunately.
I'm now using the exact example Qlik suggest on their webpage:
So I'm passing this JSON string and still getting an 'invalid request' message.
{ "jsonrpc": "2.0", "id": 0 "handle": -1, "method": "GetDocList", "params": [], }