Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Highlighted
frank_packer_at
New Contributor II

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
Employee
Employee

Re: Issue with exportData method in mashup deployed away from Qlik Server

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!

3 Replies
Employee
Employee

Re: Issue with exportData method in mashup deployed away from Qlik Server

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
New Contributor II

Re: Issue with exportData method in mashup deployed away from Qlik Server

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.

Employee
Employee

Re: Issue with exportData method in mashup deployed away from Qlik Server

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