2 Replies Latest reply on Dec 4, 2018 11:55 AM by Santhosh Sekar

    How to change the project owner using RESTAPI

    Santhosh Sekar

      Hi All,

       

      Do we have the way to change the owner of the existing project using RESTAPI? As per the below article, Im aware we can change the name and description but couldn't see a attribute to change the owner.

      https://onlinehelp.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#update_project

       

      Looking for the input if anyone face this scenario before. Thanks in advance.

        • 1. Re: How to change the project owner using RESTAPI
          Santhosh Sekar

          Hi,

           

          Can anyone help here? or appreciate if you have any other way to get this done. I hope impersonating userid with the service account is one of the option. But Im now pretty sure here.

           

          Thank you

          • 2. Re: How to change the project owner using RESTAPI
            Santhosh Sekar

            Hi Everyone,

             

            Found the way here to set the same parent project owner for the sub-projects too by impersonating a user.

             

            1. Retrieved the parent project owner ID.

             

            2. Pass the ownerID to the user id value below

            $TabSigninImPersonate = (’<tsRequest>

            <credentials name=“’ + $TabUser + ’” password=“’+ $TabPassword + ’” > <site contentUrl="’ + $TabSiteName +’"/>

            <user id="’ + $global:ProjUserTabID +’"/></credentials></tsRequest>’)

             

            3. Assign below variables and capture the token for the parent project owner user id.

            Invoke-RestMethod -Uri $TabUri/auth/signin -Body $TabSigninImPersonate -Method   #Impersonate the user

             

            TabAuthTokenImpersonate = $TabResponseImpersonate.tsResponse.credentials.token

            TabSiteIDImpersonate = $TabResponseImpersonate.tsResponse.credentials.site.id

            TabSessionUserIDImpersonate = $TabResponseImpersonate.tsResponse.credentials.user.id

            TabHeadersImpersonate = New-Object “System.Collections.Generic.Dictionary[[String],[String]]”

            TabHeadersImpersonate.Add(“X-Tableau-Auth”, $global:TabAuthTokenImpersonate)

             

            4. Use the below code to create the subproject under the parent project by passing the parent project ID and the sub-project name.

            $Subproject_request = ('<tsRequest><project  parentProjectId="' + $ParentProjectID +'" name="' + $NewProjectName +'" description="'+ $Description + '" /></tsRequest>')

             

            5. Call invoke-restmethod function to create the sub-projects and the owner would be the user whom we impersonated

            Invoke-RestMethod -Uri $TabUri/auth/signin -Body $TabSigninImPersonate -Method POST

             

            This procedure will help to impersonate the user of the parent project and create the sub-projects underneath it. Thus, the project owner would be the same for both parent and sub-projects. Also, it helps for the automation in your organization to create sub-projects and set owner and permissions.

             

            Thank you