Skip to main content

#Create토론 중인 항목 0개

Hello,

I'm trying to get all users from a subsite of our server via the API using a Server Admin PAT. But for some reason I'm getting 403 errors:

<?xml version='1.0' encoding='UTF-8'?>

<tsResponse xmlns="http://tableau.com/api"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api https://help.tableau.com/samples/en-us/rest_api/ts-api_3_21.xsd">

<error code="403010">

<summary>Forbidden</summary>

<detail>User 'administrator' is authenticated for site 'defaultsite-id' and may not access or modify resources on site 'subsite-id'.</detail>

</error>

</tsResponse>

I'm getting the xml via this url: users_url = f"{server_name}/api/{version}/sites/subsite-id/users"

 

I have already set the conentUrl to the subsite during authentication:

if use_pat_flag:

# The following code constructs the body for the request. The resulting element will

# look similar to the following example:

#

#

# <tsRequest>

# <credentials personalAccessTokenName="TOKEN_NAME"

# personalAccessTokenSecret="TOKEN_VALUE" >

# <site contentUrl="SITE_SUBPATH" />

# </credentials>

# </tsRequest>

#

 

request_xml = ET.Element('tsRequest')

credentials = ET.SubElement(request_xml, 'credentials',

personalAccessTokenName=personal_access_token_name,

personalAccessTokenSecret=personal_access_token_secret)

site_element = ET.SubElement(credentials, 'site', contentUrl=site_url_id)

I tried authenticating with a site-admin PAT for the subsite, but I'm only getting 401 errors when I try to sign in to the server (also set the contentUrl to the subsite).

How can I successfully authenticate for the subsite?

Thank you

답변 9개
  1. 2025년 6월 19일 오후 9:52

    @Thea Baldewein​ 

    Hi, as you cannot share your code, use tableau server client:

    https://tableau.github.io/server-client-python/

    import tableauserverclient as TSC

    import csv

    from datetime import datetime,timezone

     

    # server admin creds

    HOST = "https://prod-useast-b.online.tableau.com/"

    TOKEN_NAME = "Python"

    TOKEN_VALUE = "b5iXybhg==:lc65QDPxx6M"

    CONTENT_URL = "yoursitename"

     

    tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME, TOKEN_VALUE, site_id=CONTENT_URL)

    server = TSC.Server(HOST, use_server_version=True)

     

    #Create the csv file and open it in write mode

    f = open('usuarios.csv', 'w', encoding='UTF8', newline='')

     

    #delimiter with semicolon if need change to comma, and write header

    writer = csv.writer(f, delimiter=";")

    header = ['User','Site Role','Last Login','Difference']

    writer.writerow(header)

     

    today_date = datetime.now(timezone.utc)

     

    with server.auth.sign_in(tableau_auth):

    for user in TSC.Pager(server.users):

    if user.last_login is None:

    row=[user.name,user.site_role,"NA","NA"]

    print(user.name, user.site_role, "NA", "NA")

    #write the row

    writer.writerow(row)

    else:

    last_login = user.last_login

    difference = (today_date - last_login).total_seconds() / (60 * 60 * 24)

    row=[user.name,user.site_role,user.last_login,difference]

    print(user.name, user.site_role, user.last_login, difference)

    writer.writerow(row)

    #Close file connection and sign out

    f.close()

    server.auth.sign_out()

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000

I don't know what category this fits in very well, but I picked one.

 

Here is my situation:

 

1. Active Directory SSO is enabled and required by my org

2. The REST API is disabled as required by my org's security team (don't ask)

3. The AD Sync is not a sync, but an add only, so I have 100's of unlicensed users (30,327 total users)

4. Manually removing the unlicensed users via the GUI is ridiculous because I can't select all and delete

 

I am considering attempting to enable read / write account for the users table within tableau and running a powershell script to query and delete any unlicensed users.  I don't know if enabling read write on a particular table in the DB is possible and searching that hasn't given me any specific information on it.

답변 7개
  1. 2018년 5월 15일 오후 9:00

    Hi Justin,

     

    This might gain more attention in the Server Administration area.

     

    I do not believe there is a 'supported' way to have write access to the PostGres Repository on Tableau Server. You are able to have read access though, build a query against it, and then write a tabcmd command to remove the users.

     

    *There is a yml file with the superuser tblwgadmin account which is explained here but it is not supported: null

     

    You could export the list though from Tableau PostGres to a csv and use the 'tabcmd deleteusers "user.csv"  ' which is referenced here: tabcmd Commands

    One other note, you will not be able to remove users that currently are listed as owners so you would need to get a list of users that are attached to content on the server. You can also get this information from the PostGres repository though. If you run the deleteusers command and a user still has content it will leave them as 'unlicensed'

     

    If you haven't enabled access to the PostGres Repository, here is a link:Collect Data with the Tableau Server Repository

     

    Andrew

0/9000

Hello,

 

I'm trying to do some forecasting that goes beyond Tableau's built in forecasting capabilities but running into some problems. When I apply this formula (bold is the important part):

 

SCRIPT_STR("library(forecast);

predict_data <- .arg1;

log_ts <- ts(log(predict_data),frequency=52);

diff_ts=diff(log_ts); ⌗make data stationary

length=length(diff_ts)-1;

predict_data2=diff_ts[1:length]; ⌗ignore latest y count

regressors=data.frame(summer=.arg2[2:(length+1)],fall=.arg3[2:(length+1)], winter=.arg4[2:(length+1)], nwd=.arg5[2:(length+1)]); # get explanatory variable data

xreg=cbind(summer=model.matrix(~as.factor(regressors$summer)),fall=regressors$fall, winter=regressors$winter, nwd=regressors$nwd); ⌗make matrix of explanatory variables

xreg=xreg[,-1]; ⌗exclude intercept

modArima=auto.arima(predict_data2,xreg=xreg); ⌗dynamic regression model

 

season=strsplit(.arg6, ",")[[1]]; ⌗create vector of dummy variables from [Season] string season.num=as.numeric(season); ⌗convery dummy variables to numeric x=append(season.num, min(.arg7); ⌗append dummy variables with [# of NWD] for prediction vector

 

mat=matrix(x,nrow=1); ⌗xreg requires matrix

fcast=forecast(modArima,xreg=mat,h=1);

paste(predict_data[(length-1)]exp(fcast$lower)[1,1],predict_data[(length-1)]exp(fcast$upper)[1,1],sep='~') ⌗transform back and grab 80 PI", sum([y]),sum([Summer]),sum([Fall]),sum([Winter]),sum([NWD]),[Season],[# of NWD])

 

I get this error:

Error in base::parse(text = .cmd) : <text>:12:0:unexpected end of input

10: modArima=auto.arima(predict_data2,xreg=xreg); ⌗dynamic regression model

11: season=strsplit(.arg6,

^

 

[Season] is a string parameter that can take on the value of "0,0,0" "0,1,0" "1,0,0" or "0,0,1". What is weird to me is that when I try out the bolded part of the script in R, I have no issues at all.

 

Anyone know what could be causing the problem in Tableau? Thanks!

 

Sorry I can not post a workbook as the data is private.

답변 3개
0/9000

I have to create a hyper file with single table by joining multiple data frames. I have attached the code and the error message that I'm receiving. My approach is:

1- Read input data and convert to pandas data frame

2- Define temporary tables using Table definition:

3-Create Schema and add the data through iteration

4- Using SQL to join the data

Code:

  • Step 1:
  1. table_one_csv_path = "table_one.csv"
  2. table_two_csv_path = "table_two.csv"
  3. table_one = pd.read_csv(table_one_csv_path)
  4. table_two = pd.read_csv(table_two_csv_path)
  • Step 2:

with HyperProcess(telemetry=Telemetry.DO_NOT_SEND_USAGE_DATA_TO_TABLEAU) as hyper:

  1. # Creates new Hyper file ".
  2. with Connection(endpoint=hyper.endpoint, database=hyper_name,
  3. create_mode=CreateMode.CREATE_AND_REPLACE) as connection:
  4. #Create Schema
  5. connection.catalog.create_schema("Extract")
  6. # Creates multiple tables.
  7. sales = TableDefinition(
  8. table_name=TableName("Extract", "sales"),
  9. columns=[
  10. TableDefinition.Column("Product Key", SqlType.int()),
  11. TableDefinition.Column("Sales", SqlType.int())
  12. ],
  13. persistence=Persistence.TEMPORARY
  14. )
  15.  
  16. products = TableDefinition(
  17. table_name=TableName("Extract", "products"),
  18. columns=[
  19. TableDefinition.Column("Product Key", SqlType.int()),
  20. TableDefinition.Column("Product Name", SqlType.text())
  21. ],
  22. persistence=Persistence.TEMPORARY
  23. )
  • Step 3:

# I think I should not create table as in Table definition I set the persistence to Temporary, But I still receiving error --> "sales" table not found

  1. connection.catalog.create_table(sales)
  2. connection.catalog.create_table(products)
  3. with Inserter(connection, sales) as inserter_1:
  4.  
  5. for index, row in table_one.iterrows():
  6. inserter_1.add_row(row)
  7. inserter_1.execute()
  8.  
  9. with Inserter(connection, products) as inserter_2:
  10. for index, row in table_two.iterrows():
  11. inserter_2.add_row(row)
  12. inserter_2.execute()

Step 4:

  1. table_names = connection.catalog.get_table_names("Extract")
  2. path_to_database = Path(hyper_name)
  3. print(f"Tables available in {path_to_database} are: {table_names}")
  4.  
  5. joined_connections = connection.execute_command(f'CREATE TABLE "Extract"."Extract" AS SELECT * FROM {sales.table_name} as A LEFT OUTER JOIN {products.table_name} as B ON A.{escape_name("Product Key")} = B.{escape_name("Product Key")}')

 

Error Message, while Im creating table using connection.catalog.create_table()

"tableauhyperapi.hyperexception.HyperException: cannot create temporary object in non-temporary schema "

Error Message, while Im not creating the table, but keeping the persistence to Temporary:

"tableauhyperapi.hyperexception.HyperException: table "joined_hyper"."Extract"."sales" does not exist: "

답변 2개
  1. 2021년 2월 26일 오전 10:40

    Hello!

     

    The problem is, that temporary tables are only allowed to be in a temporary schema. However, your code tries to place them in the non-temporary "Extract" schema.

    I would suggest you still use temporary tables but instead of:

     

    TableName("Extract", "sales")

     

    you just use:

    TableName("sales")

     

    Then, the temporary table is automatically placed in the temp-schema.

    Also, you might want to take a look at pantab, which is a python library written by tableau users for easy and fast pandas <-> hyper conversions.

    It uses a bunch of tricks under the hood which should make it quite a bit faster than the usual approach you took in your program.

     

    Let me know if you have further questions.

     

    Cheers,

    Jonas

0/9000

Warning: Forgive me if I don't use the right terms - I am very new to tableau.

 

I am working on a project to focusing on population of people living within a selected dynamic radius distance (in km). Second part of the project is to show which of provincial road networks pass through the selected circle.

 

What I have:

 

1. Shape file of 2016 population census of the province (Saskatchewan, Canada) - down to dissemination block area units IDs (DBAUIDs). This shape file also has areas (in square kms) of all the DBAUID's.

2. Shape Map of the provincial road networks - different classes of roads, town names, metro centers, etc.

 

My main focus is to draw circles (dynamic radius) around top 9 city centers by population. And show the population living within that radius AND amount spent on maintaining road networks passing through that circle - by increasing or decreasing the radius. I found a very good example here (Richard Leeke's Super-Charged ZIP Code Radius-Finder ) but can't reproduce it as I have limited knowledge on GIS.

 

What I have done:

1. I was able to build circles using the lat/long of 9 cities - chosen manually (But I wish this can be automated for all cities and be able to select by filters).

2. I was also able to change the circle radius using a parameter.

 

I am stuck with overlaying the population files and road network files and making them work with the circles. Like I said earlier, this (workbook found here >> Richard Leeke's Super-Charged ZIP Code Radius-Finder  is exactly what I have in mind to achieve. I need help on this. Thank you for being kind enough to help me advance in Tableau. All of the definition to understand the census data are here: Table 4.12 Dissemination area boundary files record layout.

 

Message was edited by: Jim Dehner

I removed the list of "Mentioned" - see

답변 139개
  1. 2018년 12월 22일 오전 12:04

    OK, explanations for the last two views and the dashboard.

     

    Highway Spending per Capita for Selected Areas

     

    This builds on a lot of the things we did in the previous view, but has one extra twist which I'll explain first before the detailed instructions.

     

    The table calculation for the field [Amount Spent per Capita] uses the expression:

     

    [Selected Amount Spent] / [Selected Population]

     

    where both of those are themselves table calculation, but with different addressing: [Selected Amount Spent] is calculated over all roadnames whereas [Selected Population] is calculated over all dissemination blocks. This means we can't just use the 'Compute Using' menu option for [Amount Spent per Capita] to set the addressing, because that only allows us to pick one field, so only one of the two component calculations would be correct. Instead we need to use the 'Edit Table Calculation' option which gives the option to set the addressing individually for each component calculation:

    OK, explanations for the last two views and the dashboard.

    The dialog has a drop-down list allowing you to choose each component calculation in turn.

    pastedImage_5.png

     

    At first sight you would think that for 'Selected Population' you should just check [dbuid] (meaning the calculation would be performed over all [dbuid] values for each combination of [Highway Roadname] and [Population Center]) and for [Selected Amount Spent] you should check [Highway Roadname] (meaning the calculation would be performed over all [Highway Roadname] values for each combination of [dbuid] and [Population Center]). But that results in [Amount Spent per Capita] being null. This screenshot of the 'show data' window hopefully explain what is happening here: [Selected Population] is always null for highway rows and [Selected Amount Spent] is null for all dissemination block rows - so [Amount Spent per Capita] is always null (because one or other of the two fields used to calculate it is always null).

    pastedImage_2.png

     

    So actually what we need to do is perform both calculations over all values of both [Highway Roadname] and [dbuid] for each [Population Center], by setting both like this:

    pastedImage_6.png

     

    That means that both components calculations and hence the [Amount Spent per Capita] are evaluated correctly for every row, as shown here:

    pastedImage_1.png

    We will again want to filter the view down to a single row, using the [First Row?] field, as we did previously.

     

    Step by step instructions.

     

    1) Create a new sheet and call it 'Highway Spending per Capita for Selected Areas'.

    2) Drag [Population Center] from datasource 'Pop Centre Dissemination Block Highway' onto the Rows shelf.

    3) Switch to sheet 'Dissemination Blocks and Highways around Population Centers' and for both the population and population center filters select 'Apply to Worksheets' and select 'Highway Spending per Capita for Selected Areas' to apply those filters to our new sheet.

    4) Switch back to 'Highway Spending per Capita for Selected Areas' and drag [dbuid] and [Highway Roadname] onto the detail shelf.

    5) Drag [Amount Spent per Capita] onto the Columns shelf, and set the addressing using the 'Edit Table Calculation' option from the drop-down menu on the field. Select both [dbuid] and [Highway Roadname] for each of the two component calculated fields, as per the explanation above.

    6) Drag [Is First?] onto the filter shelf and select 'True' when prompted (the reason it only offers 'True' is because with the default addressing there is only one row per partition - so that row is always the first row in its partition). Now use 'Edit Table Calculation' to set the addressing to use both [dbuid] and [Highway Roadname] as above. Finally select 'True' when offered 'True' or 'False' to filter to just the first row.

    7) From the Label shelf select 'Show mark labels'.

    pastedImage_13.png

    8) Optionally format the [Amount Spent per Capita] field and axis to use currency format.

     

    Your view should now look like this for Saskatoon.

    pastedImage_14.png

     

    Highway Spending by Population Center and Route

     

    Last sheet. This one is very straightforward, no new techniques or concepts, so just brief step-by-step instructions should do.

     

    1) Create a new sheet and call it 'Highway Spending by Population Center and Route'.

    2) Drag [Population Center] from datasource 'Pop Centre Dissemination Block Highway' onto the Rows shelf.

    3) Switch to sheet 'Dissemination Blocks and Highways around Population Centers' and for both the population and population center filters select 'Apply to Worksheets' and select 'Highway Spending by Population Center and Route' to apply those filters to our new sheet.

    4) Switch back to 'Highway Spending by Population Center and Route', drag [Highway Roadname] onto the Detail shelf and [Highway Route Number1] onto the Rows shelf.

    5) Drag [Selected Amount Spent] onto the Columns shelf, and set the addressing using the 'Compute Using' option from the drop-down menu on the field. Select [Highway Roadname].

    6) Drag [Is First?] onto the filter shelf and select 'True' when prompted. Now use the 'Compute Using' menu option to set the addressing to use [Highway Roadname] as above. Finally select 'True' when offered 'True' or 'False'.

    7) From the Label shelf select 'Show mark labels'.

    8) Optionally format the [Selected Amount Spent] field and axis to use currency format.

     

    Your view should now look like this for Saskatoon.

    pastedImage_25.png

     

    One thing that is worth pointing out is that the calculated field [Selected Amount Spent] is the same field as we used on sheet 'Population and Highway Spending for Selected Areas', but gives a different answer this time because we have the route number dimension as well as population center on this sheet, so the result is broken down further.

     

    Finally create a dashboard, drag all the sheets on and arrange as you see fit.

     

    The filters should all just work on all sheets because of the way that we applied the filters from the first sheet to all of the other sheets.

     

    You will probably want to edit the titles and alias some of the entries in the legends and do various other bits of tidy up. Here's what mine looks like:

     

    pastedImage_27.png

    For extra bonus points you can do things like adding highlight actions to the dashboard so that you can click on route numbers in the bar chart and highlight the routes on the map:

     

    pastedImage_28.png

     

    I noticed that you had created extracts for both the census CSV file and the expenditure spreadsheet. That is definitely a good thing to do - after seeing that I've done it for mine and although I haven't timed it the workbook seems quicker - it is certainly really responsive. One thing you could do is recreate the census extract with a filter on province, so that you only include dissemination blocks for Saskatchewan. I don't think that will make a measurable difference to performance, but it saves a bit of space - and it's a good habit to get into, I think - no point in carrying around lots of excess data that is unrelated to what you are doing.

     

    So that's all there is to it.

     

    It has certainly turned into a much bigger exercise than I was expecting and we have covered an awful lot of ground and lots of different Tableau concepts and techniques. It's actually been really useful for me - I've been right out of the Tableau world for a long time so it's been a great chance to refresh my knowledge and get up to date on all the changes that have been happening since I was last using it regularly.

     

    As I say, I'm fully expecting some more questions (including working through the one you are stuck on at the moment). I'll get to those as and when I'm around.

     

    Good luck!

0/9000

Hi Everyone,

We've just successfully upgraded our Production environment to Tableau Server 2019.1.2. Is there a way to disable Ask Data for all data sources on the Server?

Thanks.

Muteru Mwangi

답변 20개
  1. 2019년 8월 6일 오후 6:23

    Hey everyone,

     

    Thanks for the continued discussion. The TSM commands listed above to disable the UI for the input box are not an officially supported solution. Please use the following instructions to enable/disable Ask Data for Tableau versions 2019.1 and 2019.2 (as well as the minor versions of these releases).

     

    Enable Ask Data for Data Sources - Tableau

     

    This throttle is limited to the data source. However, we are actively working on the broader enable/disable settings (at the server and site level). I will share an update in a few weeks but we are targeting 2019.4 with this added capability.

     

    Thanks,

    Ruhaab Markas

    Sr. Product Manager - Ask Data

0/9000

I have a dashboard with a filter/parameter to display the chart for the selected segment. There's dozens of segments. Is there a way to export to ppt and have each segmentation be its own page?

 

I am trying to avoid creating ~50 sheets and dashboards in tableau.

답변 1개
  1. 2025년 7월 2일 오후 2:42

    @Wes Patton​ 

    Hi, I think you may Tableau Server Client to generate a PDF (I currently don't have a PPT code).

    import tableauserverclient as TSC

    import os

    import numpy as np

    from io import BytesIO

    import PyPDF2

     

    # source information

    SOURCE_SERVER_NAME = "https://www.yourserver.com"

    SOURCE_SITE_NAME = 'yoursite'

    SOURCE_WORKBOOK_NAME = "RestApi2"

    PROJECT_NAME = "RestApi"

     

    # destination info

    TMPDIR = "PDF Merged"

    PREVIEW_FOLDER_LOCATION = os.getcwd() + "/" + TMPDIR + "/"

    PREVIEW_FILE_EXTENSION = ".pdf"

     

    ⌗Login info

    TOKEN_NAME = 'Test'

    TOKEN = 'neOMFA+Tyvw==:p48kScoLBZQILB'

    #Each element in the filter array will generate a PDF. in the element, separate with comma the values e.g. 'Material de oficina,Mobiliario'. if you want to filter several values at the same time. This will generate two PDFs, one with Material de oficina and Mobiliario, and other, filtered with Tecnologia

    FILTERS = np.array(['Material de oficina,Mobiliario', 'Tecnología'])

     

    source_server = TSC.Server(SOURCE_SERVER_NAME, use_server_version=True)

     

    ⌗Use the following to sign in with PAT

    source_tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME,TOKEN,SOURCE_SITE_NAME)

     

    with source_server.auth.sign_in(source_tableau_auth):

    print('Logged in to source server successfully')

    all_workbooks = source_server.workbooks.filter(name=SOURCE_WORKBOOK_NAME, project_name=PROJECT_NAME)

    print(len(all_workbooks))

    ⌗Download workbook to a temp directory

    if len(all_workbooks) == 0:

    print('No workbook named {} found.'.format(SOURCE_WORKBOOK_NAME))

    exit()

    elif len(all_workbooks) >= 2:

    print('Several workbooks named {} found.'.format(SOURCE_WORKBOOK_NAME))

    exit()

    elif len(all_workbooks) == 1:

    isExist = os.path.exists(TMPDIR)

    print(isExist)

    if not isExist:

    # Create a new directory because it does not exist

    os.makedirs(TMPDIR)

    print("The new directory is created!")

    try:

    for j in all_workbooks:

    ##create a pdf merger object

    PDFMerger = PyPDF2.PdfMerger()

    for k in FILTERS:

    try:

    source_server.workbooks.populate_views(j)

    print("Connected to wb")

    for i in j.views:

    # set the image request option

    pdf_req_option = TSC.PDFRequestOptions(page_type=TSC.PDFRequestOptions.PageType.Unspecified)

    # (optional) set a view filter

    print("Setting filters")

    pdf_req_option.vf('Categoría', k)

    #pdf_req_option.vf('Parameters.Year', '2018')

    source_server.views.populate_pdf(i, pdf_req_option)

    stream = BytesIO(i.pdf)

    PDFMerger.append(stream)

    except:

    pass

    PDFMerger.write(PREVIEW_FOLDER_LOCATION+PREVIEW_FILE_NAME)

    print(PREVIEW_FOLDER_LOCATION+PREVIEW_FILE_NAME)

    except:

    pass

    # Sign out

    source_server.auth.sign_out()

    If working with default site use:

    SOURCE_SITE_NAME = ''

    Note this approach needs the workbook published in Tableau Server or Tableau Cloud. Also, note this code uses PAT (Personal Access Token authentication).

    https://help.tableau.com/current/online/en-us/security_personal_access_tokens.htm

     

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000
mursid rahman 님이 #Tableau APIs & Embedding에 질문했습니다

I am writing a python script to update datasource database connection. I've got it to work to update a datasource that is using Postgres database by updating Hostname, Port, Username and Password. Using this API Reference page

 

My question is, could I do the same to update a datasource connection that is connected to Oracle database since it requires to update Service name? From the API Reference page under update_connection, it only provides feature to only update serverAddress, serverPort, userName and password.

답변 1개
  1. 2024년 11월 21일 오후 1:35

    @mursid rahman​ 

    Hi, currently you can't do it using the Rest API or TSC.

     

    As a workaround, you may use a combination of the REST API, and the Document API to make those changes. I have never done it, but I think it is possible. My suggested steps would be.

     

    a. Download the tdsx or tds using TSC.

    b. Edit the required connection fields using the document api:

    https://tableau.github.io/document-api-python/docs/

     

    However, the schema property is not documented, but taking a closer look from the source code, it seems it is supported:

    https://github.com/tableau/document-api-python/blob/master/tableaudocumentapi/connection.py

     

    This may be something like the following code, but like I said, I have not tested it. Also,

    from tableaudocumentapi import Datasource

    DS_FILENAME = "Ventas Test.tdsx"

    DS_DIRECTORY = "D:\\Tableau Server\\Document API\\"

    DS_PATH = DS_DIRECTORY + DS_FILENAME

    NEW_DS_FILENAME = "New Ventas.tdsx"

    sourceDS = Datasource.from_file(DS_PATH)

     

    #Create a loop if neccesary if several connections in the TDSX/TDS

    #sourceDS.connections[0].server = "MY-NEW-SERVER"

    #sourceDS.connections[0].dbname = "NEW-DATABASE"

    sourceDS.connections[0].schema = "NEW-SCHEMA"

    #sourceDS.connections[0].service = "NEW-SERVICE"

    #sourceDS.connections[0].port = "8040"

    #sourceDS.connections[0].username = "NEW-USER"

    sourceDS.save_as(DS_DIRECTORY + NEW_DS_FILENAME)

    c. Once the file is saved, you may publish again your datasource using Rest API or Tableau Server Client. As always, before replacing your current datasource, do some tests.

     

    I would like to have a complete code, however, I currently don't have it.

     

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000
Lilian Castro 님이 #Trailhead에 질문했습니다

 I'm unable to select "Property" at this step. What can I do? 

Please help with the

Creating Object Relationships 2.png

 

#Trailhead  #Trailhead Challenges  #Certifications  #TrailblazerCommunity

답변 5개
  1. 2024년 11월 4일 오후 9:24

    Hi @Lilian Castro I am a member of Trailhead Help, We have created a case on your behalf. We will reach out to you via email to investigate further.

     

    ++CreateTrailheadCase

     

    You can ignore the above command, it is a tool used by our Agents to tell the system to create your case. Thank you!

0/9000

Hi everyone,

 

I need to get page-based user view counts using the Python rest api. Can you support me on this issue?

답변 2개
  1. 2024년 9월 25일 오후 4:53

    @Serkan Arslan​ 

    Hi, in this case you may use Tableau Server Client:

    import tableauserverclient as TSC

    import csv

     

    # server admin creds

    HOST = "https://prod-useast-b.online.tableau.com/"

    TOKEN_NAME = "Test"

    TOKEN_VALUE = "cjcvCg==:45pE9"

    CONTENT_URL = "yoursite"

     

    tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME, TOKEN_VALUE, site_id=CONTENT_URL)

    server = TSC.Server(HOST, use_server_version=True)

     

     

    #Create the csv file and open it in write mode

    f = open('views.csv', 'w', encoding='UTF8', newline='')

     

    #delimiter with semicolon if need change to comma, and write header

    writer = csv.writer(f, delimiter=";")

    header = ['content URL','name','Owner_id','total_views']

    writer.writerow(header)

     

    today_date = datetime.now(timezone.utc)

     

    with server.auth.sign_in(tableau_auth):

    for view in TSC.Pager(server.views,usage=True):

    row=[view.content_url,view.name,view.owner_id,view.total_views]

    #print(view.conten_url,view.name,view.owner_id,view.total_views)

    #write the row

    writer.writerow(row)

    #Close file connection and sign out

    f.close()

    server.auth.sign_out()

    To use this code, you will need a PAT:

    https://help.tableau.com/current/pro/desktop/en-us/useracct.htm#create-a-personal-access-token

     

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000