Skip to content

Unable to fetch all workbooks for users.populate_workbooks(user) #930

Closed

Description

@kdutta-c

Unable to fetch all workbooks for a given user.

Versions
Details of your environment, including:

  • Tableau Online
  • Python 3.7+
  • tableauserverclient<=0.14.1

To Reproduce
`
import tableauserverclient as tsc
from tableauserverclient.server.endpoint.exceptions import ServerResponseError

    def get_workbooks_users(self) -> list: #tableau credentials are passed through Self

    list_workbooks_n_users = []
    try:
        with self.server.auth.sign_in(self.tableau_auth):
            for user in tsc.Pager(self.server.users):
                if 'tol.admin.api.broker.service.usera@tableau.com' not in user.name:
                    self.server.users.populate_workbooks(user)
                    for wkb in user.workbooks:
                        print(wkb.name, user.name)
                        list_workbooks_n_users.append({
                            'user_id': user.id,
                            'user_name': user.name,
                            'wb_id': wkb.id,
                            'wb_name': wkb.name,
                            'project_id': wkb.project_id,
                            'project_name': wkb.project_name,
                            "site_id": self.site_id
                        })
    except ValueError:
        print("some thing")
    finally:
        print("some other thing")
    return list_workbooks_n_users

`

Results
I only get the first one hundred results for my user. I know the user has access to all tableau assets.

NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.

Activity

  1. bcantoni commented on Oct 27, 2021

    @bcantoni
    Contributor

    @kdutta-c I think what's happening here is the underlying REST API call (query workbooks for user) is by default just returning 100 results.

    I think you can request more by defining a request option object:

    req_options = TSC.RequestOptions(pagesize=1000)
    

    And then using that in your populate_workbooks call:

    self.server.users.populate_workbooks(user, req_options)
    

    Let me know if that works. If so I'll repurpose this issue into a "make the request options more clear" doc bug so we can improve.

  2. kdutta-c commented on Oct 28, 2021

    @kdutta-c
    Author

    Hi @bcantoni, Thank you for your reply. It does work, but I have to supply a number of workbooks to pagesize that is equal to the number workbooks published online. Supplying 1000 doesn't work in my case. The users endpoint handled this well up until the second week of September.

  3. bcantoni commented on Oct 28, 2021

    @bcantoni
    Contributor

    Okay let me see if I understand correctly: if you have a user who has 156 workbooks, making the call with pagesize=156 does work, but setting it to a larger number like 200 or 1000 does not?

  4. kdutta-c commented on Oct 28, 2021

    @kdutta-c
    Author

    You are right. It doesn't work with RequestOptions if I used a pagesize more than 156.

  5. bcantoni commented on Oct 29, 2021

    @bcantoni
    Contributor

    Okay thanks for the confirmation. The fact that it used to work and then stopped working (presumably with a Tableau Online update) is a good clue.

  6. adrianrlaus commented on Nov 2, 2021

    @adrianrlaus

    I'm having the same issue. I'm getting a "project_id must be defined" error if I page through too many results. I'm only able to get around 140 if I play around with the page size and page number.

    I'm using the Pager generator for my function to retrieve all workbooks on the server.

  7. jacalata commented on Nov 7, 2021

    @jacalata
    Contributor

    @kdutta-c are you also getting an error for your calls, or just not seeing all the workbooks you expect?
    @adrianrlaus - are you using Collections or Personal Spaces? Is it possible that this error is returned when you first iterate over a workbook that is in a collection or personal space?

  8. kdutta-c commented on Nov 8, 2021

    @kdutta-c
    Author

    @jacalata, I don't see an error message when I put in the exact number of tableau workbooks into the parameters. Otherwise, I get an error
    ValueError: project_id must be defined.
    However, I don't think project_id was an input value before September 2021. It worked perfectly fine without it. 🤷

  9. adrianrlaus commented on Nov 9, 2021

    @adrianrlaus

    @jacalata I'm not using Collections or Personal Spaces

  10. adrianrlaus commented on Nov 22, 2021

    @adrianrlaus

    Any update on this?

  11. kdutta-c commented on Dec 21, 2021

    @kdutta-c
    Author

    Hi, Any updates / hints on how to overcome this issue?

  12. adrianrlaus commented on Dec 21, 2021

    @adrianrlaus

    Hi everyone! Updating to the latest version solved it for me

  13. kdutta-c commented on Dec 22, 2021

    @kdutta-c
    Author

    Are you sure?

    I see that class Workbook still needs project_id to run.
    Reference:

    I am trying to list all workbook names per user to know what users have access to what workbooks.

    I am trying to do this:

    def get_workbooks_users(self) -> list: #tableau credentials are passed through Self
    
    list_workbooks_n_users = []
    try:
        with self.server.auth.sign_in(self.tableau_auth):
            for user in tsc.Pager(self.server.users):
                if 'tol.admin.api.broker.service.usera@tableau.com' not in user.name:
                    self.server.users.populate_workbooks(user)
                    for wkb in user.workbooks:
                        print(wkb.name, user.name)
                        list_workbooks_n_users.append({
                            'user_id': user.id,
                            'user_name': user.name,
                            'wb_id': wkb.id,
                            'wb_name': wkb.name,
                            'project_id': wkb.project_id,
                            'project_name': wkb.project_name,
                            "site_id": self.site_id
                        })
    except ValueError:
        print("some thing")
    finally:
        print("some other thing")
    return list_workbooks_n_users
    
  14. hanishche commented on Jan 19, 2022

    @hanishche

    HI any update on this

  15. jorwoods commented on Jan 22, 2022

    @jorwoods
    Contributor

    @kdutta-c FYI, populating workbooks on a user will tell you all workbooks that that user owns, not all workbooks that they have access to. For owners, you can also use the metadata API, with a query like this:

    query wbowners {
      workbooks{
        owner{
          luid
          username
        }
        luid
        name
        projectName
        site{
          luid
          name
        }
      }
    }

    Getting all content that a user has access to is a much more complicated affair, requiring checking the permissions of every item on the server. the group membership of each user, and so on.... OR taking the equally complicated route of signing in to the site as each user and trying to query all workbooks on the server.

  16. kdutta-c commented on Jan 24, 2022

    @kdutta-c
    Author

    @kdutta-c FYI, populating workbooks on a user will tell you all workbooks that that user owns, not all workbooks that they have access to. For owners, you can also use the metadata API, with a query like this:

    query wbowners {
      workbooks{
        owner{
          luid
          username
        }
        luid
        name
        projectName
        site{
          luid
          name
        }
      }
    }

    Getting all content that a user has access to is a much more complicated affair, requiring checking the permissions of every item on the server. the group membership of each user, and so on.... OR taking the equally complicated route of signing in to the site as each user and trying to query all workbooks on the server.

    Thank you @jorwoods. Sounds interesting. I will try checking permissions based on the asset and not the user. I think, It should translate into the same output I need.

  17. jacalata commented on Feb 16, 2023

    @jacalata
    Contributor

    This should have been fixed in the linked update to tsc in mid-2022.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions