server-client-python
server-client-python copied to clipboard
fix: handle parameters for view filters
Closes #1632
Parameters need to be prefixed with "vf_Parameters." in order to be properly registered as setting a parameter value. This PR adds that prefix where it was missing, but leaves parameter names that already included the prefix unmodified.
To restate on the PR: copilot recommends changing "vf_Parameters" to "vf_parameters". But the Tableau Server query parameter is case sensitive, so it has to be "vf_Parameters". Below is a sample script I used to test this.
import os
from dotenv import load_dotenv
import tableauserverclient as TSC
load_dotenv()
server = TSC.Server(os.environ["TABLEAU_SERVER"], use_server_version=True)
auth = TSC.PersonalAccessTokenAuth(os.environ["TOKEN_NAME"], os.environ["TOKEN_SECRET"], site_id=os.environ["TABLEAU_SITE"])
with server.auth.sign_in(auth):
view = server.views.filter(name="test", workbook_name="Superstore", project_name="Samples")[0]
opts = TSC.CSVRequestOptions()
opts.parameter("Check", "sent")
server.views.populate_csv(view, opts)
for line in view.csv:
print(line.decode("utf-8").strip())