REST API calls to retrieve hi-res images/PDF from Tableau Server

Version 1

    Yesterday Jonathan Drummey asked me how to retrieve high resolution (not thumbnail) images from Tableau Server. While REST API does not have option to get images or PDF you can cheat and use REST API token to retrieve the files easily. And it will be way faster than call tabcmd - especially from programs.

     

    The process flow:

     

    $ cat > signin.xml

     

    <tsRequest>

      <credentials name="tfoldi" password="foobar" >

        <site contentUrl="" />

      </credentials>

    </tsRequest>

    $ curl "http://54.203.245.18/api/2.0/auth/signin" -X POST -d @signin.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <tsResponse xmlns="http://tableausoftware.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableausoftware.com/api http://tableausoftware.com/api/ts-api-2.0.xsd">

      <credentials token="e474bee3d0c653b12cb342d35cab86b9">

        <site id="2bc9d5f9-fdff-4715-98a6-0c4edb213961" contentUrl=""/>

        <user id="532e7b0d-f0f4-4c04-afcf-09add5018145"/>

      </credentials>

    </tsResponse>

    $ curl 'http://54.203.245.18/views/Regional/Obesity.png'  -H 'Cookie: workgroup_session_id=e474bee3d0c653b12cb342d35cab86b9' -H 'Connection: keep-alive' --compressed > Obesity.png

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                     Dload  Upload   Total   Spent    Left  Speed

    100  367k  100  367k    0     0   450k      0 --:--:-- --:--:-- --:--:--  450k

    $ file Obesity.png

    Obesity.png: PNG image data, 984 x 604, 8-bit/color RGBA, non-interlaced

     

    So from two http calls (1 = signin, 2 = get the png) you have the image in hi-res. You can repeat step two as many times as you want for other file formats or views without re-logon.