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
Error trying to update user's site_role to Viewer #853
Describe the bug
Trying to update user's site_role. I can make them 'Unlicensed' with the same code, but it doesn't work when i try to update to Viewer.
Versions
Details of your environment, including:
Tableau Server version (or note if using Tableau Online) 2020.1.6 (20201.20.0626.1424) 64-bit Windows
Python version 3.9.4
TSC library version 0.15.0
To Reproduce
CODE:
with server.auth.sign_in(tableau_auth):
for user in unlicensed:
user_to_update = server.users.get_by_id(user['id'])
user_to_update.site_role = 'Viewer'
server.users.update(user_to_update)
(unlicensed is a list of UserItem objects i need to update) Results
400013: Bad Request
Invalid site role 'Viewer'
NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.
it's a list of users and nothing weird about any of them. This script only works when I try to make them Unlicensed or Publisher. I'm Server Admin and they are unlicensed users. And I need to add 300 new users but i really don't want to do it manually :D
Server version 2020.3.1
Tableau client server 0.16.0
first I get the user from the server with
and then try to update with a new password, I haven't changed the site role
all_users, pagination_item = server.users.get()
for user in all_users:
pwd = generate_random_password(15)
user = server.users.update(user,password=pwd)
print(f"{user.name}\t{pwd}")
Traceback (most recent call last):
File "<input>", line 9, in <module>
File "/Users/code/cronjobs/python_env_39/lib/python3.9/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 163, in wrapper
return func(self, *args, **kwargs)
File "/Users/code/cronjobs/python_env_39/lib/python3.9/site-packages/tableauserverclient/server/endpoint/users_endpoint.py", line 59, in update
server_response = self.put_request(url, update_req)
File "/Users/code/cronjobs/python_env_39/lib/python3.9/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 122, in put_request
return self._make_request(
File "/Users/code/cronjobs/python_env_39/lib/python3.9/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 69, in _make_request
self._check_status(server_response)
File "/Users/code/cronjobs/python_env_39/lib/python3.9/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 86, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400013: Bad Request
Invalid site role: 'Viewer' is malformed or is not a supported user role in this version of Tableau."
I faced the same issue, this is happening because the role "Viewer" was only added on api version 3.0. If you dont specify a version while creating the server object, version 2.8 will be set as default which doesnt have the viewer role.
set use_server_version=True while creating server to automatically set the proper version.
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.
Activity
AlexVines commentedon Jun 18, 2021
also when I'm adding new users it adds them as Unlicensed
t8y8 commentedon Jun 18, 2021
A journey through the code and docs show that
Viewershould work on 2020.1.X, and the models and endpoint look correct at first glance.Is there anything weird about the user?
Are they (also) a Server Admin? You may need to check via the UI
AlexVines commentedon Jun 18, 2021
it's a list of users and nothing weird about any of them. This script only works when I try to make them Unlicensed or Publisher. I'm Server Admin and they are unlicensed users. And I need to add 300 new users but i really don't want to do it manually :D
[-]update site_role[/-][+]Error trying to update user's site_role to Viewer[/+]jacalata commentedon Aug 24, 2021
Do you know if there are server (license) or site limits on users? If so, is it possible you don't have any Viewer licenses available?
jorwoods commentedon Aug 31, 2021
@AlexVines Have you tried using
TSC.UserItem.Roles.Viewer? Could be an invalid character in your string somehow.mskempri commentedon Oct 15, 2021
I just run into the same problem.
Server version 2020.3.1
Tableau client server 0.16.0
first I get the user from the server with
and then try to update with a new password, I haven't changed the site role
rejuls commentedon Jan 10, 2022
I faced the same issue, this is happening because the role "Viewer" was only added on api version 3.0. If you dont specify a version while creating the server object, version 2.8 will be set as default which doesnt have the viewer role.
set
use_server_version=Truewhile creating server to automatically set the proper version.https://tableau.github.io/server-client-python/docs/versions.html
mskempri commentedon Jan 10, 2022
Thank you @rejuls , I ended up doing this with requests rather than the tableau server client, I will try with the package next time
github-actions commentedon Aug 6, 2026
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.
github-actions commentedon Aug 21, 2026
Closing due to inactivity. If this is still relevant, please reopen or file a new issue.