Skip to content

Issue updating connections on workbooks to datasources #703

Closed as not planned

Description

@DaniilBalabanov33N

Hi,
I'm trying to update connections on workbooks. The example provided in samples works for datasources, but when I'm updating workbooks I'm getting the following error:

400039: Bad Request
There was a problem updating connection {CONNECTION_ID} for workbook {WORKBOOK_ID}.

Maybe it's a different issue, but how would one update workbook connections to point to a different datasource on Tableau? From what I can see the connections get updated by simply overriding the attributes on the ConnectionItem class and then building an xml/text request. What I can't see is how to change datasource_name/datasource_id on the ConnectionItem class (it's private methods).

UPDATE:
I've also noticed I can not publish new workbooks. Even if I just download a wb from the server, give it a different name (By setting WorkbookItem(project_id='123', name='new_name'), and try to upload it. The error I get is:

400011: Bad Request
here was a problem publishing the file {FILE_PATH}

UPDATE:
I've managed to fix uploading issue.

I also checked the Tableau logs on updating connections on workbooks and it's throwing a java error saying: dbclass: sqlproxy is not editable (errorCode=60004)
So my question stays the same: how would one point a workbook to use a different datasource

Activity

  1. DaniilBalabanov33N commented on Oct 1, 2020

    @DaniilBalabanov33N
    Author

    Basically I'm trying to replicate this
    `for wb in wb_files:

        t_file = TableauFileManager.open(filename=wb_files[wb], logger_obj=logger)
        dses = t_file.datasources
        for ds in dses:
            if ds.is_published is True:
                # Set the Site of the published data source
                ds.published_ds_site = d_site_connection.site_content_url
                o_ds_content_url = ds.published_ds_content_url
                if o_ds_content_url in orig_ds_content_url:
                    ds.published_ds_content_url = orig_ds_content_url[o_ds_content_url].new_content_url
            # If the datasources AREN'T published, then you may need to change details directly here
        temp_wb_file = t_file.save_new_file('Modified Workbook'.format(wb))
        new_workbook_luid = d.workbooks.publish_workbook(workbook_filename=temp_wb_file, workbook_name=wb,
                                               project_obj=dest_project,
                                               overwrite=True)
        print('Published new workbook {}'.format(new_workbook_luid))
        os.remove(temp_wb_file)`
    
  2. davidhacrypto commented on Jul 19, 2022

    @davidhacrypto

    I also faced the 400039 issue, anybody have found a way to work around it?
    ServerResponseError:

    400039: Bad Request
    	There was a problem updating connection '' for workbook ''.
    
  3. added
    needs investigationIssue needs to be looked at by Tableau
    document-apiFunctionality implemented in https://github.com/tableau/document-api-python
    on Feb 17, 2023
  4. TeyTetterfio commented on Aug 7, 2023

    @TeyTetterfio

    @davidhacrypto and @DaniilBalabanov33N were you able to find a resolution to the below issue? I am experiencing the same error. I am trying to update connection email and password for the data source in a tableau workbook on Tableau Cloud using the tableauserverclient package on python and I get the same error as both of you:

    400039: Bad Request There was a problem updating connection '<connection id>' for workbook '<workbook id>'.

  5. 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.

  6. jacalata commented on Aug 25, 2026

    @jacalata
    Contributor

    Closing as not-planned. The 400039: sqlproxy is not editable error you're hitting from the Update Workbook Connection REST endpoint is a server-side limitation on how live-to-published-datasource connections can be repointed via REST — TSC just surfaces it. To repoint a workbook at a different published datasource, the working approach is to edit the .twb XML directly with document-api-python (https://github.com/tableau/document-api-python) and republish the modified file via workbooks.publish. If you can identify a case where TSC is calling the wrong endpoint or mangling the payload, please open a fresh issue.

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