Last active
November 2, 2021 21:42
-
-
Save divinorum-webb/f32a0ddb233b7cc8cf91ad7e8a215dd1 to your computer and use it in GitHub Desktop.
tableau-api-lib-create-subscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tableau_api_lib import TableauServerConnection | |
from tableau_api_lib.utils.querying import get_schedules_dataframe, get_users_dataframe, get_views_dataframe | |
SAMPLE_SCHEDULE_ID = <YOUR_SCHEDULE_ID> | |
SAMPLE_USER_ID = <USER_ID_FOR_USER_SUBSCRIBED> | |
SAMPLE_CONTENT_ID = <VIEW_OR_WORKBOOK_ID_FOR_SUBSCRIPTION> | |
SAMPLE_CONTENT_TYPE = <VIEW_OR_WORKBOOK> # this value can 'view' or 'workbook' and is not case sensitive | |
tableau_server_config = { | |
'my_env': { | |
'server': 'https://YourTableauServer.com', | |
'api_version': '<YOUR_API_VERSION>', | |
'username': '<YOUR_USERNAME>', | |
'password': '<YOUR_PASSWORD>', | |
'site_name': '<YOUR_SITE_NAME>', | |
'site_url': '<YOUR_SITE_CONTENT_URL>' | |
} | |
} | |
conn = TableauServerConnection(tableau_server_config, env='my_env') | |
conn.sign_in() | |
print(help(conn.create_subscription)) # this demos the useful info contained within each tableau-api-lib method's docstring | |
response = conn.create_subscription(schedule_id=SAMPLE_SCHEDULE_ID, | |
user_id=SAMPLE_USER_ID, | |
content_type='view', | |
content_id=SAMPLE_CONTENT_ID, | |
subscription_subject='Sample subscription subject', | |
attach_pdf_flag=True, | |
attach_image_flag=True) | |
print(response.json()) | |
conn.sign_out() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, This helps a lot. I'm planning to get the user subscription list using python code and then load it into CSV. Once the data is verified, then the plan is to use this logic to loop through those records in CSV to create subscriptions. There is no proper documentation regarding how to create subscriptions without using a manual process. The actual plan is to use Alteryx to do this, but there is very limited documentation to do the admin work using it. So came across folks using Python to do the tableau admin work.
Here is a link that I found which serves my purpose on Alteryx.
https://community.tableau.com/s/question/0D54T00000C5Oon/making-post-api-calls-to-a-tableau-server-using-alteryx
Let me know if you would like to add anything that I can do to make the above solution easier.
Thanks