Skip to content

Error trying to update user's site_role to Viewer #853

Closed as not planned
Closed as not planned

Description

@AlexVines

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.
image

Activity

  1. AlexVines commented on Jun 18, 2021

    @AlexVines
    Author

    also when I'm adding new users it adds them as Unlicensed

    image

  2. t8y8 commented on Jun 18, 2021

    @t8y8
    Contributor

    A journey through the code and docs show that Viewer should 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

  3. AlexVines commented on Jun 18, 2021

    @AlexVines
    Author

    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

  4. changed the title [-]update site_role[/-] [+]Error trying to update user's site_role to Viewer[/+] on Jun 24, 2021
  5. jacalata commented on Aug 24, 2021

    @jacalata
    Contributor

    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?

  6. jorwoods commented on Aug 31, 2021

    @jorwoods
    Contributor

    @AlexVines Have you tried using TSC.UserItem.Roles.Viewer? Could be an invalid character in your string somehow.

  7. mskempri commented on Oct 15, 2021

    @mskempri

    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

     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."
    
  8. rejuls commented on Jan 10, 2022

    @rejuls

    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.

    https://tableau.github.io/server-client-python/docs/versions.html

  9. mskempri commented on Jan 10, 2022

    @mskempri

    Thank you @rejuls , I ended up doing this with requests rather than the tableau server client, I will try with the package next time

  10. github-actions commented on Aug 6, 2026

    @github-actions

    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.

  11. github-actions commented on Aug 21, 2026

    @github-actions

    Closing due to inactivity. If this is still relevant, please reopen or file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds investigationIssue needs to be looked at by TableaustaletriagedReviewed by a maintainer; leave closed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions