diff --git a/tableauserverclient/server/endpoint/datasources_endpoint.py b/tableauserverclient/server/endpoint/datasources_endpoint.py index 88c739dc..2c595aa9 100644 --- a/tableauserverclient/server/endpoint/datasources_endpoint.py +++ b/tableauserverclient/server/endpoint/datasources_endpoint.py @@ -260,13 +260,12 @@ def publish( else: raise TypeError("file should be a filepath or file object.") - if not mode or not hasattr(self.parent_srv.PublishMode, mode): - error = "Invalid mode defined." - raise ValueError(error) - # Construct the url with the defined mode url = f"{self.baseurl}?datasourceType={file_extension}" - if mode == self.parent_srv.PublishMode.Overwrite or mode == self.parent_srv.PublishMode.Append: + if not mode or not hasattr(self.parent_srv.PublishMode, mode): + error = f"Invalid mode defined: {mode}" + raise ValueError(error) + else: url += f"&{mode.lower()}=true" if as_job: diff --git a/tableauserverclient/server/server.py b/tableauserverclient/server/server.py index 02abb3fe..30c635e3 100644 --- a/tableauserverclient/server/server.py +++ b/tableauserverclient/server/server.py @@ -119,6 +119,7 @@ class PublishMode: Append = "Append" Overwrite = "Overwrite" CreateNew = "CreateNew" + Replace = "Replace" def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=None): self._auth_token = None