8 Replies Latest reply on Nov 13, 2017 10:34 AM by Chandra Shetty

    Linking Datasource to Workbook via REST API

    Alexey Samborskiy

      Hi Tableau Community,

      I'm working on workbook publishing automation for my project and recently I created CASE 02582550 to discuss if it's possible to link already published datasource to workbook via REST API or tabcmd.

      Tableau support team suggested me to use Tableau Desktop and told me that they are looking at linking the data source to the workbook via REST API.

      Unfortunately Tableau Desktop cannot be used in my automation process and my development process is blocked.

      Is there any story in your backlog to implement linking data source to workbook? If no could you please create corresponding ticket.

       

      Best Regards

      Samborskiy Alexey

      Software Engineer

       

       

        • 1. Re: Linking Datasource to Workbook via REST API
          Chris McClellan

          I think you mean the Document API GitHub - tableau/document-api-python: Create and modify Tableau workbook and datasource files  

           

          I don't think the REST API will do what you want.

          • 2. Re: Linking Datasource to Workbook via REST API
            Alexey Samborskiy

            Hi Chris,

            Thanks for your response.

            I'm trying to solve next problem: I have workbook WB1 and datasource DS1 on tableau server in folder 'Sandbox'. Also I have datasource DS2 in folder 'Pre-Approved'. All I want is to switch DS1 to DS2 for workbook WB1 using only REST API. I know that such functionality is not yet implemented, so my question is when it could be done? Is there any development story in backlog for this, etc?

            • 3. Re: Linking Datasource to Workbook via REST API
              Chris McClellan

              I'm not an API expert, but from what I know it will be the Document API that gets this functionality, not the REST API.

               

              There was a presentation at TC16 about this, it might be worth checking that out or getting in touch with the dev's to see how far away this functionality really is.

              • 4. Re: Linking Datasource to Workbook via REST API
                Michel Roberge

                Hi Alexey,

                 

                As Chris stated, the Document API is what you need. Our scenario is similar: we want the users to take their workbook from their DEV to TEST to PROD. So obviously, the database connection information has to be updated. We support both SQL and ORACLE, so any workbook we build needs to be "importable" in any system.

                 

                We started this before the document API came into the game. As such, we "hack" the Xml (for the lack of a better term). But this works fine, and we can't justify using Python in our already complex environment, so we took that upon ourselves.

                 

                We are now working on supporting data sources instead of embeded connections. As you can well imagine, we will have the exact same situation: replace DS1 by DS2 in a workbook (connect from DEV to TEST servers for example).

                 

                Our POC works, and it's manipulating the workbook document.

                 

                So, long story short, the process is to get the TWB file through the REST API, change the data information using the document API, and publish it using the REST API.

                 

                Hope this helps a bit,

                 

                Michel

                • 5. Re: Linking Datasource to Workbook via REST API
                  Alexey Samborskiy

                  Hi Michel,

                   

                  Thanks for your response!

                   

                  I've used suggested approach with Document API and it worked for me in case when Workbook has it's own datasources inside.

                  But unfortunately the requirements for our workbooks is to use external datasources. And when I change connection information in workbook datasource(external) via Document API and publish this workbook to Tableau server workbook still uses external datasource. I guess workbook has some hidden link to external datasource, maybe such link is the name attribute from datasource tag in .twb file:

                  <datasource caption='SomeDatasource' inline='true' name='sqlproxy.11fsbas0hedh5j10vclzq0hf9t4u' version='10.0'>

                  But I'm not sure about this and I cannot check it, because I cannot retrieve such value(sqlproxy.11fsbas0hedh5j10vclzq0hf9t4u) from datasource file.

                  So I'll wait for implementing replace datasource functionality.

                  • 6. Re: Linking Datasource to Workbook via REST API
                    Michel Roberge

                    Hi Alexey,

                     

                    Actually, a datasource node is like this:

                     

                        <datasource caption='Samples A' inline='true' version='9.2' name='sqlproxy.28shbas0hedh5j10vclzq0hf9t4u'>

                          <repository-location id='SamplesA' path='/t/demo/datasources' revision='1.2' site='demo' />

                     

                    I think what matters is the Id, not the name. I gave it a try, and if I have another Datasource named Samples B, the id will be SamplesB and I can just change the above to this:

                     

                        <datasource caption='Samples B' inline='true' version='9.2' name='sample-a-this-is-just-a-name'>

                          <repository-location id='SamplesB' path='/t/demo/datasources' revision='1.2' site='demo' />

                     

                    And it works.

                     

                    But I agree - it would be simpler if such an API existed directly. But then again, you need to check that all fields match between the 2 data sources, else you invalidate your workbooks. It is not that simple.

                     

                    Regards,

                     

                    Michel

                    • 7. Re: Linking Datasource to Workbook via REST API
                      Matthew Naylor

                      HI,

                       

                      Looking to solve the same issues ourself...

                       

                      For what I can see the Document / REST API still has no method to implement this.

                       

                      Does anyone know if there are any plans to change this, or do I need to implement my own XML hacking to archive this.

                       

                       

                      Mat

                      • 8. Re: Linking Datasource to Workbook via REST API
                        Chandra Shetty

                        The workbook has reference to the published data source.  Hence you will need to update the connection's "server" reference to point to the target server & then publish.  You can use the document API to update this.

                        Keep in mind that the data source will need to be published to the target server before you can publish the workbook.