You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
400003: Bad Request Payload is either malformed or incomplete #990
import tableauserverclient as TSC
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
filename="tsc.log", level="DEBUG")
tableau_auth = TSC.TableauAuth('xxx', 'xxx', site_id='xxx')
server = TSC.Server('https://prod-apnortheast-a.online.tableau.com')
server.auth.sign_in(tableau_auth)
# create new user
newU = TSC.UserItem('Mike', 'Viewer')
server.users.add(newU)
print(newU.name, newU.site_role)
I just tried to use the api to add a new user, but it returns this:
Traceback (most recent call last):
File "D:\Application\Anaconda\envs\new_ticket_auto\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 88, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400003: Bad Request
Payload is either malformed or incomplete
and the tsc.log file return:
14:58:33,309 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): prod-apnortheast-a.online.tableau.com:443
2022-02-15 14:58:35,128 - urllib3.connectionpool - DEBUG - https://prod-apnortheast-a.online.tableau.com:443 "POST /api/3.14/auth/signin HTTP/1.1" 200 360
2022-02-15 14:58:35,135 - tableau.endpoint.auth - INFO - Signed into https://prod-apnortheast-a.online.tableau.com as user with id 10c3b3f3-9630-4f5e-ba82-xxxxxxxxx
2022-02-15 14:58:35,136 - tableau.endpoint - DEBUG - request post, url: https://prod-apnortheast-a.online.tableau.com/api/3.14/sites/a48e73ae-c557-4887-b07a-yyyyyyyy/users
2022-02-15 14:58:35,136 - tableau.endpoint - DEBUG - request content: b'<tsRequest><user name="Mike" siteRole="Viewer" /></tsRequest>'
2022-02-15 14:58:36,472 - urllib3.connectionpool - DEBUG - https://prod-apnortheast-a.online.tableau.com:443 "POST /api/3.14/sites/a48e73ae-c557-4887-b07a-yyyyyyyyy/users HTTP/1.1" 400 373
@jasonusaco I believe the problem here is in the Users documentation. The docs and examples imply that the first argument should be the user's name, but in reality what it's expecting is the email address. (At least that's the case for Tableau Online sites.)
In your example this should work instead:
newU = TSC.UserItem('mike@example.com', 'Viewer')
Could you confirm whether that works for your case? If so I'll morph this issue into a docs bug so we can get that section clarified.
@jasonusaco I believe the problem here is in the Users documentation. The docs and examples imply that the first argument should be the user's name, but in reality what it's expecting is the email address. (At least that's the case for Tableau Online sites.)
In your example this should work instead:
newU = TSC.UserItem('mike@example.com', 'Viewer')
Could you confirm whether that works for your case? If so I'll morph this issue into a docs bug so we can get that section clarified.
Activity
bcantoni commentedon Feb 15, 2022
@jasonusaco I believe the problem here is in the Users documentation. The docs and examples imply that the first argument should be the user's name, but in reality what it's expecting is the email address. (At least that's the case for Tableau Online sites.)
In your example this should work instead:
Could you confirm whether that works for your case? If so I'll morph this issue into a docs bug so we can get that section clarified.
jasonusaco commentedon Feb 16, 2022
Yes, it works! Thank you
bcantoni commentedon Feb 16, 2022
Thanks for confirming! I've created #993 as a follow-up task to clarify the docs and examples.