Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
frank_packer_at
Partner - Contributor III
Partner - Contributor III

Issue with exportData method in mashup deployed away from Qlik Server

Hi All,

I have a mashup set up and I have a simple function for exporting the data of any visualisation object to CSV

        $rootScope.exportTable = function (idToExport) {

            app.getObject(idToExport).then(function (visual) {

                var qTable = qlik.table(visual);

                qTable.exportData({

                    download: true

                });

            });

        }

This function works great when the mashup is hosted on the Qlik server, however it fails when it is hosted elsewhere.

I'm seeing a 404 error, and noting that the URL for the temp file is the server where the mashup is hosted, rather than the Qlik server where the temp file is actually being created. If I manually change the server portion of the download URL to the Qlik server, the file exists and downloads fine.

I need to be able to set the URL path for the exportData function. Has anyone encountered and subsequently solved this issue?

1 Solution

Accepted Solutions
Aiham_Azmeh
Employee
Employee

Hi frank_packer_atobi‌,

The reason why it's not working, is that the download link is relative to Qlik Sense server, you can use the callback to retrieve it:

app.getObject(idToExport).then(function (visual) {

  var qTable = qlik.table(visual);

  qTable.exportData({download: true}, function(link){

    console.log(link);// <= this will be the relative link

   // you should be able to do

   var downloadLink = 'https://[you_qlik_sense_server]'+link;

   window.open(downloadLink);

  });

});

Alternatively you can use vsiaulization API instead (see https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/C...) the exportData method in visualization API will automatically build the absolute url.

app.visualization.get(idToExport).then(function (visual) {

  visual.exportData().then(function(link){

    window.open(link);

  });

});

I hope this helps!

View solution in original post

3 Replies
Aiham_Azmeh
Employee
Employee

Hi frank_packer_atobi‌,

The reason why it's not working, is that the download link is relative to Qlik Sense server, you can use the callback to retrieve it:

app.getObject(idToExport).then(function (visual) {

  var qTable = qlik.table(visual);

  qTable.exportData({download: true}, function(link){

    console.log(link);// <= this will be the relative link

   // you should be able to do

   var downloadLink = 'https://[you_qlik_sense_server]'+link;

   window.open(downloadLink);

  });

});

Alternatively you can use vsiaulization API instead (see https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/C...) the exportData method in visualization API will automatically build the absolute url.

app.visualization.get(idToExport).then(function (visual) {

  visual.exportData().then(function(link){

    window.open(link);

  });

});

I hope this helps!

frank_packer_at
Partner - Contributor III
Partner - Contributor III
Author

Thanks Aiham,

The first solution works fine.

Curiously, the second solution was something I'd already tried, but the callback function of exportData does not return anything and so that way does not appear to work as expected. I would prefer to use the Visualization API, so if you're aware of what might be happening there, I'd greatly appreciate any further input.

Aiham_Azmeh
Employee
Employee

The 2 apis work differently on with callback (qTable) and the other as a promise (visualization API)