Skip to content

Server REST API version seems to default to 2.3 and does not let me create connections on a Workbook #862

Description

@ramdesh

Describe the bug
I have Tableau version 2020.3 installed which has REST API version 3.9. I am using TSC to automate uploading Workbooks to environments, and want to create a ConnectionItem object to go with the workbook. However, I get the error

/tableauserverclient/server/endpoint/endpoint.py:175: UserWarning: 'connections' not available in 2.3, it will be ignored. Added in 2.8
  warnings.warn(error)

and the request fails with a 500 Internal Server Error.

Versions
Details of your environment, including:

  • Tableau version: 2020.3
  • Python version: 3.8
  • TSC library version: 0.15.0

To Reproduce
Here's my entire code:

import tableauserverclient as TSC
import os
import logging.config
import glob

USERNAME = ""
PASSWORD = ""
SERVER_URL = ""
PROJECT_NAME = ""
DB_USER = ""
DB_PWD = ""
DB_URL = ""
DB_PORT = ""

LOG_CONFIG = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "simple": {
            "format": "[%(asctime)s] [%(levelname)s] [%(name)s] "
            "[%(module)s:%(lineno)d] %(message)s"
        },
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "level": "DEBUG",
            "formatter": "simple",
            "stream": "ext://sys.stdout",
        }
    },
    "loggers": {
        "outcomes_reporting_deploy": {
            "level": os.getenv("LOG_LEVEL", "INFO"),
            "handlers": ["console"],
        }
    },
}
logging.config.dictConfig(LOG_CONFIG)
logger = logging.getLogger("outcomes_reporting_deploy")


tableau_auth = TSC.TableauAuth(USERNAME, PASSWORD)
server = TSC.Server(SERVER_URL)
server.version = "3.9"

with server.auth.sign_in(tableau_auth):
    logger.info("Signed in to Tableau server.")
    all_project_items, pagination_item = server.projects.get()
    all_projects = [{project.name: project.id} for project in all_project_items]
    if PROJECT_NAME and any(PROJECT_NAME in project for project in all_projects):
        wb_item = TSC.WorkbookItem(project_id=[project[PROJECT_NAME] for project in all_projects
                                               if PROJECT_NAME in project][0])
        workbooks_to_be_deployed = glob.glob('./*.twb*')
        if workbooks_to_be_deployed:
            connection_item = TSC.ConnectionItem()
            connection_item.server_address = DB_URL
            connection_item.server_port = DB_PORT
            connection_item.username = DB_USER
            connection_item.password = DB_PWD
            for workbook in workbooks_to_be_deployed:
                logger.info(f"Uploading workbook {workbook}")
                server.workbooks.publish(
                    wb_item,
                    workbook,
                    mode=TSC.Server.PublishMode.Overwrite,
                    # connection_credentials=TSC.ConnectionCredentials(
                    #     name=DB_USER,
                    #     password=DB_PWD,
                    #     embed=True
                    # ),
                    connections=[connection_item]
                )

        else:
            logger.info("No workbook(s) found to deploy. Exiting the process..")
    else:
        logger.error("No Project Name passed or unable to find a given project on the server")

**Results**

/tableauserverclient/server/endpoint/endpoint.py:175: UserWarning: 'connections' not available in 2.3, it will be ignored. Added in 2.8
warnings.warn(error)

Error status code: 500
b'

Internal Server ErrorThe server encountered an error and cannot complete your request. Contact your server administrator.'


**NOTE:** Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions