Qlik Community

Ask a Question

Integration, Extension & APIs

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

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
sanchayan
Creator
Creator

"Invalid Params" Error when connecting to Qlik Sense Engine API using Python

Hi All,

I am able to connect to Qlik Sense Desktop Engine API using this below python script :

from websocket import create_connection

import json

ws = create_connection("ws://localhost:4848/app/")

data_1=json.dumps({

'jsonrpc': '2.0',

'id': 0,

'method': 'OpenDoc',

'handle': -1,

'params': ['C:\\Users\\sbhowmik\\Documents\\Qlik\\Sense\\Apps\\Converter.qvf']

})

data_2=json.dumps({

'jsonrpc': '2.0',

'id': 5,

'method': 'GetConnections',

'handle': 1,

'params': []

})

print("Sending request 1...")

ws.send(data_1)

print("Sent")

print("Receiving...")

result_1 = ws.recv()

print("Received '%s'" % result_1)

print("Sending request 2...")

ws.send(data_2)

print("Sent")

print("Receiving...")

result_2 = ws.recv()

print("Received '%s'" % result_2)

ws.close()

 

The message I get in return from engine is as below :

{"jsonrpc":"2.0","method":"OnConnected","params":{"qSessionState":"SESSION_CREATED"}}

{"jsonrpc":"2.0","id":5,"error":{"code":-32602,"parameter":"Invalid handle","message":"Invalid Params"}}

 

 

>> Problem Statement : But, the app Test.qvf does not open up AND also, I do not get any QReturn message from the Engine API . I dont understand that why even this Invalid Param message is showing up every time. I maybe doing something wrong here. Please help.

Labels (7)
2 Replies
jonathandienst

I have not interacted with the API in Python but in javascript, I have to serialize the JSON before sending it:

ws.send(JSON.stringify(msg));
 
"msg" is a JSON object. I expect the same applies to Python (the websocket does not care about the language of the caller).
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
sanchayan
Creator
Creator
Author

I too am not much aware about python but I think JSON.dumps(msg) does the same thing as JSON.stringify(msg).

Regards,

Sanchayan Bhowmik