Repository navigation
xml.etree.ElementTree.ParseError: mismatched tag #347
Description
Hello,
I am having an issue with an update_connection push. This code works on our 10.5 AWS based server, but not our 2018.1 AWS based server. It runs through the GET commands just fine, but errors when it tries to update the connection. Thanks in advance for any help.
tableau_auth = TSC.TableauAuth('username', 'pw',site_id='mysite') # , site_id='prod'
search_string = 'servername' # use pipe '|USDAL...' for additional search criteria
search_string_regex = search_string.replace('.','\.') # replace periods with escape character
replace_string = '123.45.67.899' # use if server name/address is changing
overwrite_credentials = True # set to false to use existing credentials
replace_username = sys.argv[1] # us if
replace_pw = sys.argv[2]
request_options = TSC.RequestOptions(pagesize=1000)
server = TSC.Server('https://www.myserver.com') # tableau server
server.version = '3.0'
#Update published data sources
y = 0
with server.auth.sign_in(tableau_auth):
all_workbooks, pagination_item = server.workbooks.get(req_options=request_options)
# print(len(all_workbooks))
for wb in all_workbooks:
server.workbooks.populate_connections(wb)
for item, conn in enumerate(wb.connections): # make sure to iterate through all connections in the workbook
if wb.connections[item].connection_type != 'sqlproxy': # sqlproxy indicates published datasource
if re.search(search_string_regex, wb.connections[item].server_address, re.IGNORECASE):
connection = wb.connections[item]
connection.server_address = replace_string
if overwrite_credentials:
connection.embed_password = True
connection.username = replace_username
connection.password = replace_pw
server.workbooks.update_connection(wb, connection) # this is where it breaks
y = y + 1
ERROR:
Traceback (most recent call last):
File "C:/Users/310209207/OneDrive - Philips/PycharmProjects/Master/Tableau_DC_Changes_AWS.py", line 50, in
server.workbooks.update_connection(wb, connection)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 114, in wrapper
return func(self, *args, **kwargs)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\workbooks_endpoint.py", line 100, in update_connection
server_response = self.put_request(url, update_req)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 83, in put_request
content_type=content_type)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 54, in _make_request
self._check_status(server_response)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 66, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\exceptions.py", line 17, in from_response
parsed_response = ET.fromstring(resp)
File "C:\Python\lib\xml\etree\ElementTree.py", line 1315, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: mismatched tag: line 7, column 2
Activity
graysonarts commentedon Oct 11, 2018
Can you try setting debugging on the requests module and post the data that is coming back from the response? You can find information on how to enable it here: https://stackoverflow.com/questions/16337511/log-all-requests-from-the-python-requests-module
schefs26 commentedon Oct 12, 2018
Here are debug results...
DEBUG:urllib3.connectionpool:https://www.myserver.com:443 "GET /api/3.0/sites/20399901-69cb-42ae-93a5-fad4d5fb2f89/workbooks/fda742af-ac47-4255-8abe-52e327a4eea1/connections HTTP/1.1" 200 349
DEBUG:tableau.endpoint:b''
DEBUG:tableau.endpoint:Server response from https://www.myserver.com/api/3.0/sites/20399901-69cb-42ae-93a5-fad4d5fb2f89/workbooks/fda742af-ac47-4255-8abe-52e327a4eea1/connections:
DEBUG:urllib3.connectionpool:https://www.myserver.com:443 "PUT /api/3.0/sites/20399901-69cb-42ae-93a5-fad4d5fb2f89/workbooks/fda742af-ac47-4255-8abe-52e327a4eea1/connections/236ed7d2-4c52-41d7-9dfd-da9bee5af9d9 HTTP/1.1" 501 495
DEBUG:tableau.endpoint:[Truncated File Contents]
DEBUG:urllib3.connectionpool:Resetting dropped connection: www.myserver.com
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (2): www.myserver.com:443
DEBUG:urllib3.connectionpool:https://www.myserver.com:443 "POST /api/3.0/auth/signout HTTP/1.1" 204 0
DEBUG:tableau.endpoint:[Truncated File Contents]
INFO:tableau.endpoint.auth:Signed out
Traceback (most recent call last):
File "C://PycharmProjects/Master/Tableau_DC_Changes_AWS.py", line 54, in
server.workbooks.update_connection(wb, connection)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 114, in wrapper
return func(self, *args, **kwargs)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\workbooks_endpoint.py", line 100, in update_connection
server_response = self.put_request(url, update_req)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 83, in put_request
content_type=content_type)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 54, in _make_request
self._check_status(server_response)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 66, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace)
File "C:\Python\lib\site-packages\tableauserverclient\server\endpoint\exceptions.py", line 17, in from_response
parsed_response = ET.fromstring(resp)
File "C:\Python\lib\xml\etree\ElementTree.py", line 1315, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: mismatched tag: line 7, column 2
schefs26 commentedon Oct 16, 2018
@RussTheAerialist- Thanks for the quick reply- let me know if you have any ideas from my logs. We had a server migration this past weekend and are going one by one to update the connections- really hoping I can get this working ASAP. Again- this works on our 10.5 server perfectly. Thanks in advance.
schefs26 commentedon Oct 17, 2018
UPDATE- I believe the issue is not related to the XML... if I run the PUT command directly in the API (without TSC)... I get the unsupported request error below. I also get this on other PUT requests. Seems like it may be an issue with our server not allowing PUTs? Seems like the API is working since I can run the GET & POST requests.
I'll close this issue and submit a new one with Tableau to see if they can help. If anyone has any ideas, feel free to comment.
<TITLE>Unsupported Request</TITLE>Unsupported Request
PUT to http**myPUTcommand** not supported.Reference #8.cc00fea5.1539796776.121cdd85
irwando commentedon Jul 30, 2019
Closing this issue as @schefs26 last comment.