Skip to content

Publish datasource and connection elements #1057

Closed

Description

@jorwoods

Describe the bug
It appears to me that the publish datasource method utilizes a connectionCredentials subelement, and not a connections element.

https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#publish_data_source

The way I see it, we could solve this by one of two routes:

  1. Combine the connections and connection_credentials inside the function call to a single object that gets passed to the publish request factory.
  2. Make connection credentials accept a sequence, and surface an error to TSC users when they provide both.

Versions
Details of your environment, including:

  • Tableau Server version (or note if using Tableau Online) N/A
  • Python version 3.8.10
  • TSC library version 0.19.0

Activity

  1. jacalata commented on Jun 28, 2022

    @jacalata
    Contributor

    Yes - I'm trying to figure out how this happened, but so far it's a mystery.
    I think we want to end up with just the connection_credentials option as a sequence, but I'll take a look to see if there's a way we can temporarily support both inputs.

  2. jorwoods commented on Jun 28, 2022

    @jorwoods
    ContributorAuthor

    Looking at it again, workbook endpoint's publish method uses a connections element instead of a connection_credentials element. I think if we leave both inputs there, but just provide a warning, then the function signature can be the same between workbook and datasource.

    What I have resorted to doing in my client code is to publishing the datasource, then running update_connection after it was published. Passing only connection_credentials to the datasource publish is technically ambiguous because you can put multiple connection_credentials elements as children to the datasource element. If you have multiple connections to different databases, with the same username but different passwords... How would the API know which credential is supposed to go with which connection?

    That has me leaning towards option 1, IMO.

  3. jorwoods commented on Jun 3, 2024

    @jorwoods
    ContributorAuthor

    Circling back to this. I think the best option might be to mirror the workbook.publish endpoint and have it be connections=Sequence[ConnectionItem]. I think that would support the most scenarios and have the benefit of keeping the workbook and datasource endpoints as similar.

  4. jacalata commented on Aug 25, 2026

    @jacalata
    Contributor

    The datasource publish signature now mirrors workbook.publish: datasources.publish(..., connection_credentials=None, connections=None, ...) accepts either a single ConnectionCredentials OR a Sequence[ConnectionItem], and passing both raises RuntimeError('You cannot set both connections and connection_credentials') (see tableauserverclient/server/request_factory.py DatasourceRequest._generate_xml). This matches the recommendation in the last comment on this thread. Closing as completed and removing the in-progress label.

  5. removed
    in-progressIssues that are in-progress of being fixed
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions