
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Export visualization data using Qlik Engine JSON API
Hi everyone,
Our organization uses Qlik Sense Enterprise and we are looking to automate the download process of the data used for visualizations (format can be excel or csv) instead of the manual process which leads to the following (cropped screenshot shown):
For our use case, lets assume there is only one app which has one sheet inside and that sheet has 3 visualizations.
I have written a python script which currently has been connected to the localhost and I am able to retrieve the app_id, sheet_id and the id of the 3 charts present using Qlik Engine JSON API. The code works in the following manner:
- Fetch the doc_list (app_list)
- Select the app, since we have only one app we choose index as 0
- Create a session object (I saw Qlik Engine on Dev Hub exhibiting this behaviour which is why I executed this step)
- Get the layout of the app
- Select the sheet, since we have one sheet we choose index as 0
- Iterate through the visualizations and print their names
I have uploaded the code here: https://pastebin.com/VdDBMzAJ
I have explored a lot of pages of this community and ExportData seems to be the way to go but I am not able to write the correct JSON request for it. For reference, the output I get in my terminal on executing the python script is given below. I am quite new to this and I would be very thankful for any help from all of you.
{'jsonrpc': '2.0', 'id': 1, 'result': {'qDocList': [{'qDocName': 'Test_2.qvf', 'qConnectedUsers': 0, 'qFileTime': 44188.190983796296, 'qFileSize': 851968, 'qDocId': 'C:\\Users\\mohdm\\Documents\\Qlik\\Sense\\Apps\\Test_2.qvf', 'qMeta': {'hassectionaccess': False, 'encrypted': False}, 'qLastReloadTime': '2020-12-22T19:12:22.245Z', 'qTitle': 'Test_2', 'qThumbnail': {}}]}}
{'jsonrpc': '2.0', 'id': 2, 'result': {'qReturn': {'qType': 'Doc', 'qHandle': 1, 'qGenericId': 'C:\\Users\\mohdm\\Documents\\Qlik\\Sense\\Apps\\Test_2.qvf'}}, 'change': [1]}
{'jsonrpc': '2.0', 'id': 3, 'result': {'qReturn': {'qType': 'GenericObject', 'qHandle': 2, 'qGenericType': 'SheetList', 'qGenericId': '4b344780-a350-48db-8b65-27bb5a2c62b2'}}, 'change': [2]}
{'jsonrpc': '2.0', 'id': 4, 'result': {'qLayout': {'qInfo': {'qId': '4b344780-a350-48db-8b65-27bb5a2c62b2', 'qType': 'SheetList'}, 'qMeta': {'privileges': ['read', 'update', 'delete', 'exportdata']}, 'qSelectionInfo': {}, 'qAppObjectList': {'qItems': [{'qInfo': {'qId': '8a0f6a01-ef89-4d65-821f-371c26208dcf', 'qType': 'sheet'}, 'qMeta': {'privileges': ['read', 'update', 'delete', 'exportdata'], 'title': 'Sheet_1', 'description': ''}, 'qData': {'rank': None, 'thumbnail': {'qStaticContentUrl': {}}, 'columns': 24, 'rows': 12, 'cells': [{'name': 'kfxNpV', 'type': 'auto-chart', 'col': 0, 'row': 0, 'colspan': 15, 'rowspan': 6, 'bounds': {'y': 0, 'x': 0, 'width': 62.5, 'height': 50}}, {'name': 'qHzmARQ', 'type': 'qlik-barplus-chart', 'col': 0, 'row': 6, 'colspan': 21, 'rowspan': 6, 'bounds': {'y': 50, 'x': 0, 'width': 87.5, 'height': 50}}, {'name': 'BXBQmw', 'type': 'auto-chart', 'col': 15, 'row': 0, 'colspan': 9, 'rowspan': 6, 'bounds': {'y': 0, 'x': 62.5, 'width': 37.5, 'height': 50}}], 'title':
'Sheet_1', 'description': ''}}]}}}}
kfxNpV
qHzmARQ
BXBQmw
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To anyone interested, I had asked this question on Stack Overflow and got the answer from Stefan Stoichev.
The rough code I wrote in Python which uses request via Qlik Engine JSON API instead of enigma.js which works on Node.js is currently downloading 6 folders for 3 objects, i.e., it is downloading the files twice however the excel file contains the correct data. I am working on removing this problem and will post the updated code if anyone is interested.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To anyone interested, I had asked this question on Stack Overflow and got the answer from Stefan Stoichev.
The rough code I wrote in Python which uses request via Qlik Engine JSON API instead of enigma.js which works on Node.js is currently downloading 6 folders for 3 objects, i.e., it is downloading the files twice however the excel file contains the correct data. I am working on removing this problem and will post the updated code if anyone is interested.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure about Python, but I find that usually the hard part is getting the authentication right. Libraries like the ones that exist for JavaScript typically simplifies this a lot. Personally I tend to use C# for these kind of gadgets where the .NET SDK provides operators for doing the plumbing work for you. This is an example of what it could look like using such an environment using these two nuget packages:
https://www.nuget.org/packages/QlikSense.NetSDK/
https://www.nuget.org/packages/QlikSenseRestClient/
This code downloads xlsx files for all visualizations on the first sheet of the app.
var location = Location.FromUri(uri);
location.AsNtlmUserViaProxy();
var restClient = new RestClient(uri);
restClient.AsNtlmUserViaProxy();
using (var app = location.App(new AppIdentifier {AppId = appId}))
{
var theSheet = app.GetSheets().First();
var objs = theSheet.GetChildInfos().Select(info => app.GetGenericObject(info.Id));
foreach (var o in objs)
{
var exportResult = o.ExportData(NxExportFileType.EXPORT_OOXML);
var data = restClient.GetBytes(exportResult.Url);
using (var writer = new BinaryWriter(new FileStream(o.Id + ".xlsx", FileMode.OpenOrCreate)))
{
writer.Write(data);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I'm looking for a feature similar to yours, I'm interested if you have the final part 🙂
