9 Replies Latest reply on Oct 16, 2019 12:44 PM by Charlie Wolfe

    Rest API Publish Workbook and embed credentials

    Charlie Wolfe

      I have been able to publish a workbook successfully but the embed flag doesn't appear to be working as I am always prompted for the password when I visit the workbook on the server.

      I can't figure out whether I have a syntax issue or there's something else I'm missing.

       

      <tsRequest>

         <workbook name="Metrics Monitor2">

            <connections>

               <connection serverAddress="serverA.net" serverPort="1521">

                  <connectionCredentials embed="true" name="Charlie" password="password" />

               </connection>

            </connections>

            <project id="11077c614-c71e-483c-86a9-5a26c32bf7b6" />

         </workbook>

      </tsRequest>'

        • 1. Re: Rest API Publish Workbook and embed credentials
          Glen Robinson

          Hi Charlie

          Looking at the API refrence page

          Reference-Tableau Server REST API - Tableau

           

          It looks like you have the wrong Request Body syntax

           

          If you update it to the following, then it should work

           

          <tsRequest>

          <connection serverAddress="server-address" serverPort="port" userName="connection-username" password="connection-password" embedPassword="embed-password"  />

          </tsRequest>

           

          All the best

          Glen

           

          1 of 1 people found this helpful
          • 2. Re: Rest API Publish Workbook and embed credentials
            Charlie Wolfe

            Hi Glen, I'm looking under the Publish Workbook method under API reference and it shows the following..

             

             

            <tsRequest>

            <workbook name="workbook-name" showTabs="show-tabs-flag" generateThumbnailsAsUser="user-id">

            <connections>

                  <connection serverAddress="server-address" serverPort="port-number">

                       <connectionCredentials name="connection-username" password="connection-password" embed="embed flag" /> 

                  </connection>

            </connections>

            <project id="project-id"/>

            </workbook>

            </tsRequest>

            1 of 1 people found this helpful
            • 3. Re: Rest API Publish Workbook and embed credentials
              Glen Robinson

              Hi Charlie

              Have been testing this using my test server (2019.1), and the internal Repository

              This appears to be working for me OK.

              Are you able to test a similar scenario to see if this works for you?

               

               

              --6691a87289ac461bab2c945741f136e6

              Content-Disposition: name="request_payload"

              Content-Type: text/xml

               

               

              <tsRequest>

                 <workbook name="http_requests1" showTabs="False">

              <connections>

              <connection serverAddress="tableau.server.local" serverPort="8060">

              <connectionCredentials name ="readonly" password ="password" embed ="True"/>

              </connection>

              </connections>

                   <project id="e2de67ed-b2c2-4dcc-a654-79e158d9bb6c" />

                </workbook>

              </tsRequest>

              --6691a87289ac461bab2c945741f136e6

              Content-Disposition: name="tableau_workbook";filename="3.twb"

              Content-Type: application/octet-stream

              1 of 1 people found this helpful
              • 4. Re: Rest API Publish Workbook and embed credentials
                Elliott Stam

                Hi Charlie,

                 

                Did you ever get the embedded credentials to work properly? I am encountering what appears to be a similar issue. Publishing a .twbx workbook with an extract via API is not storing the password, even though I set the embed flag to true. The workbook file publishes correctly, but the credentials are not embedded.

                 

                Curiously, when I then enter a password for the connection through Tableau's web browser interface, I receive a message that says the password has been embedded. When I then attempt to run an extract refresh, the job fails with "DataSourceException: Missing Password".

                 

                There is no issue with the exact same workbook when publishing directly from Tableau Desktop. When published from Tableau Desktop, the password is properly embedded and the extracts run successfully. This has me stumped.

                 

                -Elliott

                • 5. Re: Rest API Publish Workbook and embed credentials
                  Akshar Jamgaonkar

                  Hi Elliott Stam,

                   

                  Are you using the tableau_tools library? You can check the library, we have used this and successfully able to copy workbooks and data stores with password embeded https://github.com/bryantbhowell/tableau_tools

                  • 6. Re: Rest API Publish Workbook and embed credentials
                    Elliott Stam

                    Hi Akshar,

                     

                    I got it working, for me it was a matter of not including the OAuth attribute at all in the request when OAuth was not present. Once that was no longer part of the request body, the credentials were embedded properly.

                     

                    -Elliott

                    • 7. Re: Rest API Publish Workbook and embed credentials
                      Ciara Brennan

                      Thanks for this update, Elliott. Hopefully this will help resolve the same query for fellow Tableau users.

                       

                      • 8. Re: Rest API Publish Workbook and embed credentials
                        Ciara Brennan

                        Hi Charlie Wolfe

                        If you have a couple of minutes could you please take this quick survey around your experience on the Tableau Community Forums?

                        ***Tell us about your experience on the Tableau Community Forums***

                         

                        Much appreciated
                        Ciara

                        [Program Manager | Tableau Community Forums]

                         

                         

                        • 9. Re: Rest API Publish Workbook and embed credentials
                          Charlie Wolfe

                          So realized I never replied once I figured out the answer.  Thanks to Tableau support I discovered I was using embedPassword instead of embed which are different actions.  Not sure how this happened.  I believe I was rapidly trying several different changes and forgot to change it back.

                           

                          This code works

                           

                          # Build a general request for publishing

                          xml_request = ET.Element('tsRequest')

                          workbook_element = ET.SubElement(xml_request, 'workbook', name=workbook_filename,  showTabs='False')

                          connections_element = ET.SubElement(workbook_element, 'connections')

                          connection_element = ET.SubElement(connections_element, 'connection',serverAddress='HOSTNAME', serverPort='PORT#')

                          ET.SubElement(connection_element, 'connectionCredentials', name="USERNAME", password="PASSWORD", embed="True")

                          ET.SubElement(workbook_element, 'project', id=project_id)

                           

                          xml_request = ET.tostring(xml_request)