2 Replies Latest reply on Jun 4, 2018 9:31 AM by James Lamb

    Publish workbook with Tableau Rest API

    James Lamb

      Hi,

      I am trying to automate the deployments of tableau workbooks and datasources.

      Having explored the tabCMD option and found that is seriously flawed as it still does not support nested workbooks I have decided that the Rest API is probably the next best option for me given the requirements.

       

      To give a bit of background in what I am trying to achieve:

      Currently we are using a product called "Octopus Deploy" for our automated deployments.

      I am trying to write a reusable library for tableau deployments that can be plugged into Octopus.

       

      Octopus relies heavily on powershell for automation of its deployments and so ideally I would like to make the rest call using powershell.

       

      After playing around with the Tableau Rest API I cannot for the life of me workout how to successfully publish a workbook.

      Other commands all work perfectly but I am plagued by either a "bad gateway" or "bad request" message when I try to publish.

       

      My message body is defined below:

      --2d3d418f6d6841c19ae25c9252a6698d
      Content-Disposition: name="request_payload"
      Content-Type: text/xml
      
      
      <tsRequest>
        <workbook name="IQ_OPTIMIZED">
          <project id="ea94a418-5049-4149-b181-dc3d5f5b4aea"/>
        </workbook>
      </tsRequest>
      
      
      --2d3d418f6d6841c19ae25c9252a6698d
      Content-Disposition: name="tableau_workbook"; filename="IQ_OPTIMIZED.twbx"
      Content-Type: application/octet-stream
      <FILE CONTENTS GO HERE> (REMOVED BECAUSE THE FILE IS 237,000KB)
      
      --2d3d418f6d6841c19ae25c9252a6698d--
      
      
      
      
      
      
      
      
      

       

      A simple curl request using powershell:

      $body = get-content C:\IQ_OPTIMIZED.twbx
      
      try{
          Invoke-WebRequest "http://tableau-test/api/2.8/sites/341f9e3f-86ac-4daa-9cf5-13cca0a32297/workbooks" -body $body -method post
      }catch{
          write-warning "$($_.Exception.Message)"
          Handle-TableauRestError $_
      }
      
      

       

       

      The following command using "tabCmd" works fine but it does not allow me to publish to nested projects

      & tabcmd.exe publish C:\IQ_Optimized.twbx --site OilGas --project Analytics -u admin -p xxxxxxxx --overwrite
      

       

       

      If someone could point me in the direction of where I am going wrong I would be very appreciative.

      I do not require a powershell solution (although this would be best)

       

      Just some pointers on how to get this to work using a simple curl call would be great.