3 Replies Latest reply on Aug 8, 2018 11:52 AM by madhuri.tanniru

    REST API Call - Update datasource now

    madhuri.tanniru

      Hi,

       

      Can someone please help with the following call [powershell]

       

      The following this throwing 400 bad request error

       

      $path = "https://uat/api/3.0"

      Function runExtractRefresh ([string] $siteid, [string] $datasourceID, [string] $aToken){

          # set up header fields with auth token

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

          # add X-Tableau-Auth header with our auth token

          $headers.Add(“X-Tableau-Auth”, $aToken)

       

          $uri = "$path"+"sites/$siteid/datasources/$datasourceID/refresh"

       

          $reqBody = (’<tsRequest>

                       </tsRequest>’)

          write-host $reqBody

       

          $response = Invoke-RestMethod -Uri $uri -Headers $headers -Body ($reqBody) -Method Post

       

          $jobID  = $response.tsResponse.job.id

          $dsID   = $response.tsResponse.extractRefreshJob.datasource.id

          $dsName = $response.tsResponse.extractRefreshJob.datasource.name

          return $jobID, $dsID, $dsName    

      }

       

      $jobID, $dsID, $dsName = runExtractRefresh $siteid $ID $auth

       

      Thanks,

      Madhuri