
I am using "Tableau Server Client(Python) and Python 3.9" and trying to download the data source and publish to a server.
when i try to parse through all available data sources i am able to download the data source file, however, when i try to find the data source associated with a workbook i am unable to download it.
I am trying to download the data source associated with a workbook but unable to do so.
here is the relevant code
```
with server.auth.sign_in(tableau_auth):
"""
for ds in TSC.Pager(server.datasources):
if ds.project_name == "project_name":
print(ds.id)
fp = server.datasources.download(ds.id)
print("\n downloaded the file to {0}", format(fp))
"""
#the above works
for workbook in TSC.Pager(server.workbooks):
if workbook.project_name == "project_name":
server.workbooks.populate_connections(workbook)
for con in workbook.connections:
ds = server.datasources.get_by_id(con.datasource_id)
server.datasources.download(ds.id) ⌗this does not work and give a 404 error
```
please check my comments inline where the i get 404 error when trying to download data source associated with a workbook
the datasource id seems to be different when checking server.datasources and server.workbooks. for example the below code produce this output
```
for ds in TSC.Pager(server.datasources):
if ds.project_name == "Test(Akshar)":
print(ds.id)
for workbook in TSC.Pager(server.workbooks):
if workbook.project_name == "Test(Akshar)":
server.workbooks.populate_connections(workbook)
for con in workbook.connections:
print(con.datasource_id)
```
produces this output
```
f648e7c4-d3e2-4ca9-8b65-59a42cc28a35
364fd4d8-ae62-4051-b59b-8ef3fdd624d7
3fdd7fcc-9052-474c-bf17-45636e2b1060
```
If it's embedded in the workbook, as a .twbx, I would guess is you can convert it to a .zip file, extract the file, and then you'll be able to pull the data source out of the data folder. I have no idea how to do that in Python, but hopefully, this helps you down the road a bit. -Mark