4 Replies Latest reply on Feb 13, 2018 2:13 PM by Jeff D

    TSC Python Library isn't Returning Data

    jesse.jenken

      Following the guide here: API reference  I'm using the Python TSC to pull a list of users from multiple Tableau servers.

       

      The problem I'm having is when looping over the users returned, users.email isn't populated, nor are several other features.

       

      I'm newer with the API and my current perception is the TSC library isn't working, but I'm completely open to it being something I'm not-doing correctly.

       

      I've tried pasting my code multiple times but this forum doesn't seem to support indented Python code.  My apologies for the below mess:

       

      import tableauserverclient as TSC
      tableau_auth = TSC.TableauAuth('my_user_name','my_rest_api_password')
      server_list = [
      'https://tableau.server.com'
      ]
      
      
      
      
      for url in server_list:
      server = TSC.Server(url)
      
      
      with server.auth.sign_in(tableau_auth):
      all_users, pagination_item = server.users.get()
      print("\nThere are {} user on {}: ".format(pagination_item.total_available, url))
      # Display all users
      # print([user.name for user in all_users])
      for user in all_users:
      print('Username: {}\nRole: {}\nLast Login: {}\nEmail: {}'.format(user.name, user.site_role, user.last_login, user.email))
      
        • 1. Re: TSC Python Library isn't Returning Data
          Zhouyi Zhang

          Hi, Jesse

           

          I can use your sample code to get the list of users with the information you desired with administrator role, but if your login user is a interactor role, it doesn't have enough privilege to access the user information.

           

          Hope this helps

           

          ZZ

          • 2. Re: TSC Python Library isn't Returning Data
            Jeff D

            Hi Jesse, the TSC documentation says that users.get() calls the Get Users On Site REST API.  If you look at that API, you'll see that it returns limited user information -- in particular, information relevant to the user on the site.

            1 of 1 people found this helpful
            • 3. Re: TSC Python Library isn't Returning Data
              jesse.jenken

              Thanks, Jeff.  This makes sense, but I'm confused by the documentation of the library itself which states fullname and email are properties of the UserItem class...  I'm able to reference them without it throwing an unbound error, but they're just empty?

               

              You're talking about this response here, right?

               

              <tsResponse> <user id="user-id" name="user-name" siteRole="site-role" lastLogin="last-login-date" externalAuthUserId="authentication-id-from-external-provider" fullName="user-full-name" authSetting="auth-setting" /> <domain name="user-domain" /> </tsResponse>

               

               

              What am I missing?  Why is Zhouyi Zhang reporting success related to server roles when my user is most-certainly a Server Administrator?  How do I pull the rest of the user information? 

               

              Thanks again

              • 4. Re: TSC Python Library isn't Returning Data
                Jeff D

                Hi Jesse, if you look at the UserItem class, you'll see that it's used wherever there's a need to work with user information.  It's an all-in-one class and is not specific to any API.  If you look at the users.update method, you'll see that it uses the email field (for setting the email information, not retrieving it).

                 

                TSC is a wrapper library meant to provide a simpler way of working with the REST API.  However, if you really want to understand the APIs, the REST API documentation is the best place to look.  That's why the TSC documentation has links directly to each REST API method.

                 

                I don't see a method for pulling the rest of the user information; perhaps I missed it, so take a look yourself in the REST API documentation.

                 

                Good luck!