2 Replies Latest reply on Sep 13, 2017 6:04 AM by Sreelatha Kandi

    Response to preflight request doesn't pass access control check

    Sreelatha Kandi

      We have a .Net web application with CanJS framework on the front end. One of the features we'd like for our users to have is the ability to upload tableau worksheets from within the app without having to login to our tableau server. We would want them to be able to do most of what they would otherwise do (managing workbooks, sources, users, etc) on tableau server, right from our app. Toward that, we want to leverage the Tableau REST api.

       

      I am able to login to our tableau server, query sites/projects/users, create a new site/project, update a site/project using tableau REST api via ajax. Although, I am not able to download or publish tableau datasources/workbooks. Following is a code snippet with which I’m attempting to download a datasource.

      The siteId I supply is a valid siteId and the token is also valid (one I get after successful login to the server).

       

                      $.ajax({ 
                                       type: 'GET', 
                                       url: "http://<tableau-server>/api/2.3/sites/" + siteId + "/datasources/c0f8ba1b-953a-45c9-9225-334a42c1c180/content", 
                                       headers: { 
                                                       'X-Tableau-Auth': token 
                                       }, 
                                       success: function(response) { 
                                                       console.log("==============> download datasource success call"); 
                                       }, 
                                       error: function (xhr, ajaxOptions, thrownError){   
                                                       console.log(xhr.status);           
                                                       console.log(thrownError); 
                                       } 
                       }).fail(function() { 
                                       alert("AJAX call failed!"); 
                       });
      

       

      But I see the following CORS error in my browser console.

       

      CORS_preflight_error.PNG

       

      Help appreciated. Thanks!