I wrote the below python code to export the users list from tableau server and it perfectly works for extracting data from one single site. But lets say we need to extract the data from multiple sites in the same time, then tableau gives me an error.
tis is the code I ran
from tableau_api_lib import TableauServerConnection
import pandas as pd
from tableau_api_lib.utils.querying import get_users_dataframe
tableau_server_config = {
'my_env': {
'server': 'https://myserver.com',
'api_version': '3.21',
'username': 'user',
'password': 'pass',
'site_name': ['FT','INT','ss'],
'site_url': ['FT','INT','ss']
}
}
conn = TableauServerConnection(tableau_server_config, env='my_env')
conn.sign_in()
users_df = get_users_dataframe(conn=conn)
users_df.drop(columns=['domain', 'externalAuthUserId', 'locale','language'], inplace=True)
print(users_df)
error -
PaginationError:
The Tableau Server REST API method decorator did not return paginated results.
Please verify that your connection is logged in and has a valid auth token.
If using personal access tokens, note that only one session can be active at a time using a single token.
Also note that the extract_pages() method wrapping this call is intended for paginated results only.
Not all Tableau Server REST API methods support pagination.
Is there any way to solve this issue? and in front the output i need to get the site name as well.
any one can help me out?
thanks
That library has a switch sites method. You only need to have one site in your config dictionary. Here's how I use it to export all users for all sites and creating a column for the site name based on its url value.
This will query the sites available and place into a data frame.
I create empty lists to append to. One for the users df for each site and one for the response values in case you need to debug.