3 Replies Latest reply on Sep 13, 2018 9:59 PM by patrick.byrne.0

    Python Rest API Retrieve Image

    Charlie Qin

      Hi folks,


      I have some code that was working before but has suddenly stopped working.


      # -*- coding: utf-8 -*-
      import datetime


      import tableauserverclient as TSC


      username = 'my_username'
      password = 'my_password'
      site_id = 'my_site'

      tableau_auth = TSC.TableauAuth(username, password, site_id=site_id)
      server = TSC.Server('https://10ay.online.tableau.com')

      # Stringify todays' date
      today = str(datetime.date.today())

      with server.auth.sign_in(tableau_auth):
         all_datasources, pagination_item = server.datasources.get()
         print("\nThere are {} datasources on site: ".format(pagination_item.total_available))
         print([datasource.name for datasource in all_datasources])

         req_option = TSC.RequestOptions()

         all_views, pagination_item = server.views.get(req_option)
         view_item = all_views[0]

         image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High)

         print('Populating image')
         server.views.populate_image(view_item, image_req_option)

         print('Got image')

         image_filepath = 'some_path.png'
         with open(image_filepath, "wb") as image_file:

      This code above used to work just fine.


      Now however I get the following error


      400074: Bad Request

        There was a problem querying the image for view 'image_hash_goes_here'.


      If I however use the populate_preview_image, everything works fine and I get a nice little preview image, like such


      print('Populating image')

      print('Got image')

      image_filepath = 'some_path.png'
      with open(image_filepath, "wb") as image_file:


      We're on the latest tableauserverclient 0.7 with Tableau Sever 2018.2


      Anyone else able to make this work?