4 Replies Latest reply on Nov 27, 2017 1:43 PM by Jason Lloyd

    RequestOptions() functionality in TableauServerClient isn't working

    Barbara Knowles

      Hi.

       

      I have a user who'd like an automated way to delete multiple users from her site.  Right now I'm just trying to delete one user.  I have the username so I need to identify the user_id.  Eventually, I'd like to build a script that can delete multiple users, probably using a file. She gets a list from HR.

       

      Last week I learned about the REST API and I started teaching myself python at the beginning of October so now I'm working on a python script.

       

      At first, I thought the problem was with my code, but I get the same "Invalid Syntax" error with the sample code.

       

      Here is my code:

      tableau_auth = TSC.TableauAuth(user_name, password)

      server = TSC.Server(server_name)

      with server.auth.sign_in(tableau_auth):

          req_option = TSC.RequestOptions()

          req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,TSC.RequestOptions.Operator.Equals,'lkane01')

          matching_user, pagination_item = server.users.get(req_option)

          #user-id=users.get

          server.users.remove(matching_users)

       

      And here is the sample:

      tableau_auth = TSC.TableauAuth(user_name, password)

      server = TSC.Server(server_name)

      with server.auth.sign_in(tableau_auth):

      req_option = TSC.RequestOptions()

          req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,

                                       TSC.RequestOptions.Operator.Equals,

                                       'Mapping College ROI')

          matching_workbooks, pagination_item = server.workbooks.get(req_option)

       

          print(matching_workbooks[0].name)

       

      Note: I substituted Mapping College ROI, which is the name of a workbook on my site, for the name in the sample.

       

      I get a syntax error for matching_users in my code and matching_workbooks in the sample code.

       

      Does anyone have any idea what's going on?  Is there an error in the sample code that I've based my code off of?

       

      I'd appreciate any assistance or, alternatively, an idea of how to build a script for my ultimate goal to remove multiple users where we will still only have a list of the user name/login...

       

      Thanks so much.  This community has been really helpful.