Skip to content

Instantly share code, notes, and snippets.

@divinorum-webb
Created April 18, 2020 03:53
Show Gist options
  • Save divinorum-webb/08900c968c1a39df909805a939ac121d to your computer and use it in GitHub Desktop.
Save divinorum-webb/08900c968c1a39df909805a939ac121d to your computer and use it in GitHub Desktop.
Creating Tableau Server webhooks using tableau-api-lib.
from tableau_api_lib import TableauServerConnection
from tableau_api_lib.utils.querying import get_webhooks_dataframe
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(config_json=tableau_server_config, env='my_env')
conn.sign_in()
# view internal documentation for creating webhooks
help(conn.create_webhook)
# create a webhook that triggers when a datasource refresh begins
response = conn.create_webhook(webhook_name='webhook_datasource_refresh_started',
webhook_source_api_event_name='webhook-source-event-datasource-refresh-started',
url='<YOUR_DESTINATION_URL>')
print(response.json())
# create a webhook that triggers when a datasource refresh succeeds
response = conn.create_webhook(webhook_name='webhook_datasource_refresh_succeeded',
webhook_source_api_event_name='webhook-source-event-datasource-refresh-succeeded',
url='<YOUR_DESTINATION_URL>')
print(response.json())
# get Pandas DataFrames containing your workbook and datasource details
webhooks_df = get_webhooks_dataframe(conn)
print(webhooks_df)
conn.sign_out()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment