1 Reply Latest reply on Dec 27, 2017 9:55 AM by patrick.byrne.0

    help! "Bad Request" when attempting to publish workbook with ds

    Damian Hickey

      Hi,

       

      I am using the Tableau server-client-python library found here: GitHub - tableau/server-client-python: A Python library for the Tableau Server REST API

       

      I am trying to publish a .twb workbook with a mysql data source. The data source has been created in Tableau Online, and the .twb file references this Tableau Online data source (datasource_name1).

      I have used populate_connections to add the data source to the server object before calling workbooks.publish, however I still get the following:

       

              400011: Bad Request

                      There was a problem publishing the file 'trial2.twb'.

       

      Can someone provide guidance as to the proper way to upload a twb with a datasource?

       

      Any help is much appreciated. Code below:

       

      I am attempting to upload a workbook to Tableau Online.

      server = 'https://us-west-2b.online.tableau.com'
      filepath = 'trial2.twb'
      try:
       tableau_auth = TSC.TableauAuth(tableau_username, tableau_password, 'livecloud')
       server = TSC.Server(server)
      except Exception as e:
       print e
      
      with server.auth.sign_in(tableau_auth):
       overwrite_true = TSC.Server.PublishMode.Overwrite
       all_projects, pagination_item = server.projects.get()
       default_project = next((project for project in all_projects if project.is_default()), None)
       try:
        if default_project is not None:
         datasource =  server.datasources.get_by_id('f54c50e0-ed6d-4468-9f92-ad6b2255ab54')
         server.datasources.populate_connections(datasource)
         print(datasource.connections[0].server_address)
         new_workbook = TSC.WorkbookItem(default_project.id)
         new_workbook = server.workbooks.publish(new_workbook, filepath, overwrite_true)
         print("Workbook published. ID: {0}".format(new_workbook.id))
        else:
            error = "The default project could not be found."
            raise LookupError(error)
       except Exception as e:
        print e