0 Replies Latest reply on Dec 3, 2019 5:15 AM by Eldar Damari

    Download Workbook csv/pdf/png using GET request

    Eldar Damari

      Hi,

       

      • tableau server version: 2019.3
      • Javascript API version: 2.2.2

       

       

      I'm using Javascript API in my web app, displaying workbooks across tabs, I'm performing authentication via trusted server and with the generated ticket I create my viz.
      One of the feature I have is downloading workbook with custom URI, currently the user will trigger the Download Report CSV button, and it override window.location.href and it will download the report automatically in CSV format.

       

      window.location.href = workbook_url
      


      My next feature I require to alert the user when the report finish downloading, and show progress. Currently it's not possible with href mechanism, so I tried using GET request to my custom workbook url.

      The issue now is that my tableau server blocks the request due to CORS

       

      This the error message:

      Access to fetch at 'https://tableau_server.com/views/****/?Start%20Date%20Param=2019-11-03 from origin 'https://web_app.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

       

      Actions taken:

       

      fetch(url ,{
         method: "GET",    
         headers: { 
           "Access-Control-Allow-Origin": "*",
           "Content-Disposition": "form-data",
           "credentials": 'include'
      }
      })
      

       

      I'm trying to deliver our clients basic functionally, without using the export dialog (it's very basic for us).
      And track the downloading  process with a better UX.

      Will be more than happy to hear how you overcome this.

       

      Thanks for the help,
      Eldar