Skip to content

Instantly share code, notes, and snippets.

@divinorum-webb
Last active November 2, 2021 21:42
Show Gist options
  • Save divinorum-webb/f32a0ddb233b7cc8cf91ad7e8a215dd1 to your computer and use it in GitHub Desktop.
Save divinorum-webb/f32a0ddb233b7cc8cf91ad7e8a215dd1 to your computer and use it in GitHub Desktop.
tableau-api-lib-create-subscription
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()
@LaxmanThakur
Copy link

I am creating automatic subscribtion for tableu server using this script but getting issue while running script
IMG_20211102_214051__01

@LaxmanThakur
Copy link

@divinorum-webb can you please help me out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment