If I had two views with the name "breakdowns" in two separate workbooks, let's say A and B, how would I add this information to my script tell Tableau I want it to print the view of 'Breakdowns' in worbook 'B'?
with server.auth.sign_in(tableau_auth):
req_option = TSC.RequestOptions()
req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
TSC.RequestOptions.Operator.Equals, 'Breakdowns'))
view_item, pagination_item = server.views.get(req_option)
server.views.populate_image(view_item, image_req_option)
Reposting here as well:
import tableauserverclient as TSC
TABLEAU_PATNAME = 'XXXX'
TABLEAU_PATSECRET = 'XXXX'
TABLEAU_HOSTNAME = 'https://XXXX.XXXXX.com'
tableau_auth = TSC.PersonalAccessTokenAuth(TABLEAU_PATNAME, TABLEAU_PATSECRET, 'XXXX')
server = TSC.Server(TABLEAU_HOSTNAME, use_server_version=True)
with server.auth.sign_in(tableau_auth):
request_option = TSC.RequestOptions()
request_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, 'Workbook B'))
all_workbooks, pagination_item = server.workbooks.get(request_option)
for wb in all_workbooks:
server.workbooks.populate_views(wb)
for view in wb.views:
if view.name == 'Breakdowns':
image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High)
server.views.populate_image(view, image_req_option)
with open('Breakdowns.png', 'wb') as image_file:
image_file.write(view.image)
break