1 Reply Latest reply on Feb 14, 2018 8:09 AM by Glen Robinson

    Tableau Rest Api

    Nivitha N

      Is it possible to pass url parameter while querying the view ? like the way we do in tabcmd

       

      tabcmd.sh export http://server.com/sites/site_name/views/view_name?:param1=value1 --png

       

       

       

      Thanks,

      Nivitha.

        • 1. Re: Tableau Rest Api
          Glen Robinson

          Hi Nivitha

          AFAIK, this is not yet possible.

          You are able in Tableau 10.5 to download images, PDF and data, but not able to attach a filter to it.

          If you are looking to re-create the functionality of Tabcmd (in exporting views, PDF) without installing Tabcmd, I have been able to do this by passing through the Auth token you receive when connecting using REST API.

          Below is a script (in powershell) that demonstrates this (exporting a PDF)

          Hope this helps

          Glen

           

          $server = "http://localhost"

          $username = "glen"

          $password = "password"

          $siteID =""

           

           

          # Login to Server using REST API method

          # generate body for sign in

          $signin_body = (’<tsRequest>

            <credentials name=“’ + $username + ’” password=“’+ $password + ’” >

             <site contentUrl="’ + $siteID +’"/>

            </credentials>

          </tsRequest>’)

           

           

          $Uri = "$server/api/2.5/auth/signin"

             $response = Invoke-RestMethod -Uri $uri -Body $signin_body -Method Post 

           

             # get the auth token, site id and my user id

             $authToken = $response.tsResponse.credentials.token

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

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

             $authToken

           

           

          # File to download (including Refresh Data, and Filter)

          $URL = "http://localhost/views/Superstore/Product.pdf:?refresh=yes&Region=South"

           

           

          $webClient = New-Object System.Net.WebClient

          $webClient.Headers.Add([System.Net.HttpRequestHeader]::Cookie, "workgroup_session_id="+$authToken)

          #$webClient.DownloadString($Url)

          $destination = "C:\temp\test.pdf"

          $webClient.DownloadFile($URL, $destination)

           

           

          # Sign Out of Server using REST API

          $response = Invoke-RestMethod -Uri $server/api/2.5/auth/signout -Headers $headers -Method Post