5 Replies Latest reply on May 18, 2017 7:02 AM by Colin Roy-Ehri

    Using the Restful API to add a guest user to a workbook

    Colin Roy-Ehri

      How can you use the API to add the Guest user to a workbook?  I'm aware that I should be able to add the Guest to a workbook using https://onlinehelp.tableau.com/current/api/rest_api/en-us/help.htm#REST/rest_api_ref.htm#Add_Workbook_Permissions%3FTocP…

       

      However, I need the correct User Id for the Guest user in the request body. I'm happy to do a DB lookup if that's the only way - I couldn't find the Guest in the results of a getUsers API call.

        • 1. Re: Using the Restful API to add a guest user to a workbook
          Jeff Strauss

          I tested out the "get users on site" method within Postman, and wasn't able to find the guest when I tried to apply a filter, but when I changed the pagesize to 1000 which is the max and then did a search on guest, I could find it and managed to find the id for my deployment when I did a search for guest on the result set.

           

          Doesn't work:

          http://servername/api/2.4/sites/xxxxxxxxxxxxxxxxxxxx/users?filter=name:eq:guest

           

           

          Works:

          http://servername/api/2.4/sites/xxxxxxxxxxxxxxxxxxxx/users?pageSize=1000

          <user id="xxxxxxxxxx" name="guest" siteRole="Guest" externalAuthUserId="" />

          1 of 1 people found this helpful
          • 2. Re: Using the Restful API to add a guest user to a workbook
            Colin Roy-Ehri

            Thanks!  Unfortunately, I have > 30,000 users, so that would take some looping and searching to make it an automated lookup. 

             

            It's odd that the filter doesn't work. Even filtering for siteRole:eq:guest does not pull it.

            • 3. Re: Using the Restful API to add a guest user to a workbook
              Jeff Strauss

              if it's a one time thing to find the guest internal id, then you could just append the page number and hunt for the guest account.  &pageNumber=2

              1 of 1 people found this helpful
              • 4. Re: Using the Restful API to add a guest user to a workbook
                SANDIP SHARMA

                Hi Colin Roy,

                 

                Hi Cristina,

                 

                If I understood your problem correctly then you want to export your data into CSV by passing filters on the dashboard pragmatically. I did the same for your using Power Shell scripting. Power Shell has capability to loop in your all the filter values which need to be passed in your dashboard one by one.

                 

                If your values are not fixed then create a separate dashboard for the values which will we passed as filter in your original dashboard.

                For Example: You have created a sheet of your Employees details by each department. In this case Department will be your key which will be passed in this dashboard to create individual CSV file for each department.

                 

                 

                Create a separate sheet which will contain only Department details init and publish the same to server. and your original dashboard which contains the info of all the employees for each department and place a filter of Department in it and publish the same to server. now use below script which will help you in generating the CSV files for each department

                 

                 

                Clear

                $view_url = "RegionDetails/Department"

                $saved_file = "F:\TS Learning\User Creation Alert to User\Department.csv"

                Set-Location "C:\Program Files\Tableau\Tableau Server\10.2\extras\Command Line Utility"

                .\tabcmd.exe login -s your server -t your_site -u user -p password

                .\tabcmd export "$($view_url)?:refresh=yes" --csv  -f "$saved_file"

                .\tabcmd logout

                $csvfile = import-csv -path $saved_file

                $view_url = "/views/RegionDetails/Employee_Dashbaord"

                foreach ($line in $csvfile)

                {

                $view_url = "/views/RegionDetails/Employee_Dashbaord" + ".pdf?Show=Show&Department=$($line.Department)"

                $saved_file = "F:\TS Learning\PDF\$($line.Department).pdf"

                Set-Location "C:\Program Files\Tableau\Tableau Server\10.2\extras\Command Line Utility"

                .\tabcmd.exe login -s your server -t your_site -u user -p password

                .\tabcmd get "$view_url" -f "$saved_file"

                .\tabcmd logout

                }

                 

                In my case I created PDF replace the .pdf with .csv.

                 

                If you have any problem in above script please feel free to write me.

                1 of 1 people found this helpful
                • 5. Re: Using the Restful API to add a guest user to a workbook
                  Colin Roy-Ehri

                  Thanks for all the details, Sandeep!  It is a good idea to set the page number.  In my case, I'm connecting from a java application to the API.  I think we'll use a jdbc connection to check the database (bypassing the API) to search for users with the username of 'guest'.  Then we can get the UUID back without the pagination and search hassle.