Skip to content

[Type 3] Publish directly using Datasource/Workbook objects from the Document API #1092

Closed

Description

@eschranz

Description

Unless this functionality already exists, it would be helpful to directly use created Datasource/Workbook objects from the Document API as the source when publishing content via TSC. Currently, you have to pass a filepath or a file object, which I haven't found an example of. This would also reduce having to save files to the file system for quick on the fly datasource/workbook creation.

from tableaudocumentapi import Connection, Datasource
import tableauserverclient as tsc

ds = Datasource.from_connections(caption="", connections=[some_connection])

# do login magic, get information for publish
server.datasources.publish(
    datasource_item=tsc.DatasourceItem(project_id, "My Cool Datasource"),
    file=ds, # object? item?
    mode=server.PublishMode.Overwrite,
    connection_credentials=tsc.ConnectionCredentials(username, password),
)

Activity

  1. nosnilmot commented on Jan 13, 2023

    @nosnilmot
    Contributor

    This should already be possible:

    import io
    from tableaudocumentapi import Connection, Datasource
    import tableauserverclient as tsc
    
    ds = Datasource.from_connections(caption="", connections=[some_connection])
    
    # do login magic, get information for publish
    
    # Save as a file-like object in memory
    dsblob = io.BytesIO()
    ds.save_as(dsblob)
    
    server.datasources.publish(
        datasource_item=tsc.DatasourceItem(project_id, "My Cool Datasource"),
        file=dsblob,
        mode=server.PublishMode.Overwrite,
        connection_credentials=tsc.ConnectionCredentials(username, password),
    )

    Downloading from Tableau Server to such a file-like object by TSC is not yet supported (see #1172), but publishing should work.

  2. github-actions commented on Aug 18, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.

  3. jacalata commented on Aug 25, 2026

    @jacalata
    Contributor

    Closing as completed. This is already possible today using the recipe nosnilmot posted in this thread: save your Document API Datasource / Workbook object to an io.BytesIO() via save_as(), then pass that BytesIO as the file argument to workbooks.publish() / datasources.publish(). TSC's publish endpoints have accepted file-like objects for a while, so no new TSC surface is needed. If you hit a specific mismatch (e.g., a filetype detection edge case), please open a fresh issue with a reproducer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions