From df5685e7e44ca4ae7b9d180c7d051f5ff875c4cf Mon Sep 17 00:00:00 2001 From: Bryant Howell Date: Mon, 17 Feb 2020 08:57:17 -0600 Subject: [PATCH 1/2] bugfix to build_url_parameter_string --- tableau_rest_api/methods/rest_api_base.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tableau_rest_api/methods/rest_api_base.py b/tableau_rest_api/methods/rest_api_base.py index 72e3355..5c78934 100644 --- a/tableau_rest_api/methods/rest_api_base.py +++ b/tableau_rest_api/methods/rest_api_base.py @@ -187,13 +187,12 @@ def build_api_url(self, call: str, server_level: bool = False, def build_url_parameter_string(map_dict: Optional[Dict] = None, name_value_tuple_list: Optional[List[Tuple]] = None, hand_built_portion: Optional[str] = None): encoded_list = None - if len(name_value_tuple_list) == 0: - encoded_list = None - else: - for v in name_value_tuple_list: - if len(v) != 2: - raise InvalidOptionException('Each element should have a two-element Tuples (Name, Value)') - encoded_list = urlencode(name_value_tuple_list) + if name_value_tuple_list is not None: + if len(name_value_tuple_list) > 0: + for v in name_value_tuple_list: + if len(v) != 2: + raise InvalidOptionException('Each element should have a two-element Tuples (Name, Value)') + encoded_list = urlencode(name_value_tuple_list) if hand_built_portion is not None and encoded_list is None: final_string = hand_built_portion From 4235b2aad4bff49b598d6626c4ac52907baa8812 Mon Sep 17 00:00:00 2001 From: Bryant Howell Date: Mon, 17 Feb 2020 09:01:07 -0600 Subject: [PATCH 2/2] Fix for open Issue 80 in update_datasource_connection and update_workbook_connection --- tableau_rest_api/methods/datasource.py | 2 +- tableau_rest_api/methods/workbook.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tableau_rest_api/methods/datasource.py b/tableau_rest_api/methods/datasource.py index 2b25f35..db97857 100644 --- a/tableau_rest_api/methods/datasource.py +++ b/tableau_rest_api/methods/datasource.py @@ -125,7 +125,7 @@ def update_datasource_connection_by_luid(self, datasource_luid: str, new_server_ new_connection_username: Optional[str] = None, new_connection_password: Optional[str] = None) -> ET.Element: self.start_log_block() - tsr = self.__build_connection_update_xml(new_server_address, new_server_port, + tsr = self.rest_api_base.__build_connection_update_xml(new_server_address, new_server_port, new_connection_username, new_connection_password) url = self.build_api_url("datasources/{}/connection".format(datasource_luid)) diff --git a/tableau_rest_api/methods/workbook.py b/tableau_rest_api/methods/workbook.py index 2bd87bd..db80e3e 100644 --- a/tableau_rest_api/methods/workbook.py +++ b/tableau_rest_api/methods/workbook.py @@ -166,7 +166,7 @@ def update_workbook_connection_by_luid(self, wb_luid: str, connection_luid: str, new_connection_username: Optional[str] = None, new_connection_password: Optional[str] = None) -> ET.Element: self.start_log_block() - tsr = self.__build_connection_update_xml(new_server_address, new_server_port, new_connection_username, + tsr = self.rest_api_base.__build_connection_update_xml(new_server_address, new_server_port, new_connection_username, new_connection_password) url = self.build_api_url("workbooks/{}/connections/{}".format(wb_luid, connection_luid)) response = self.send_update_request(url, tsr)