server-client-python
server-client-python copied to clipboard
Unable to match schedule to subscription to get all subscription details including the schedule and when it last successfully emailed
Unable to match schedules to subscriptions. The schedule_id in the subscription result set does not match any of the schedule id from the schedule result set. What am I missing here?
Versions
- Python 3.9.13
- Tableau Online
- TSC 0.17.0
To Reproduce ` import tableauserverclient as TSC import os from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv()) token_name = os.environ.get('token_name') token_secret = os.environ.get('token_secret') site_name = os.environ.get('site_name')
tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_secret, site_name) server = TSC.Server('https://10ay.online.tableau.com', use_server_version=True)
scheds = {}
with server.auth.sign_in(tableau_auth): for schedule in TSC.Pager(server.schedules): scheds[schedule.id] = schedule.name try: for subscription in TSC.Pager(server.subscriptions): if subscription.target.type == 'View': view = server.views.get_by_id(subscription.target.id)
workbook = server.workbooks.get_by_id(view.workbook_id)
view_url = view.content_url
print("workbook > view :" + workbook.name + " > " + view.name)
userid = subscription.user_id
user = server.users.get_by_id(userid)
print(user.fullname + " <" + user.name + ">")
print("subject: ", subscription.subject)
print("message: ", subscription.message)
if subscription.attach_image == True:
print("Image export")
if subscription.attach_pdf == True:
print("PDF export")
print("\tpage orientation: ", subscription.page_orientation)
print("\tpage size: ", subscription.page_size_option)
# print("schedule: ", subscription.schedule_id)
print (scheds[subscription.schedule_id])
print("-------\n")
except:
print("something went wrong")
` Results workbook > view :xxxxx > xxxxxxx Xxxx Xxxx [email protected] subject: xxx message: xxxx Image export PDF export page orientation: PORTRAIT page size: LETTER something went wrong
I believe it's possible for the schedule field to be empty, which could perhaps cause this? Try catching the error and print it out to get more info, like this
except Exception as ex: print(ex)
Hi jacalata, actually I did the data extraction for the subscriptions and schedules separately with no problems. It's just that the schedule_id in the subscription data set didn't match with any records (id) in the schedule data set. The content_id in the subscription data set matches perfectly with the id in the view/workbook data set and I can see the schedule on Tableau Online when I look at individual subscriptions. So I can't figure out why the subscription.schedule_id doesn't match with schedule.id.
Hello Swang-es,
I have checked on my end and data is matching, can you please check once again and show any sample?
workbook > view :Details Dashboard> Daily Alert Response status: <Response [200]> NAME <NAMEID> subject: Procurement - Daily Alert message: None Image export schedule: 3877375d-000000000000-c8ba4dd4448d 3877375d-1111111111111111-c8ba4dd4448d Daily 8 AM (Subscription)