Skip to main content

When you use the Website GUI to add tags you can put a space in the tag with no problem. But when you use the API to do it it seems to fail. Is this a bug, correct functionality or am I doing something wrong?  When I add tags that have spaces the API overrides the command and breaks it apart. 

 

The python code I am running is

workbook.tags = create_tag_set(workbook, tag)

server.workbooks.update(workbook)

and the tag set is ['StaleTag:LAST_USED_NEVER', 'source_projectName:Content Migration Tool (CMT) To Demo']

Code:

workbook.tags = create_tag_set(workbook, tag_set)

server.workbooks.update(workbook)

 

Results:

2023-01-27 13:42:34,209 root INFO SQL Results:

Site Name: Default

Site ID: 1

Project Name: Content Migration Tool (CMT) To Demo

Project ID: 40650

Workbook Name: World Indicators

Workbook ID: f058c5bd-3dde-476f-b01b-1787d935f6c1

Last Viewed Date: None

Days since Last Viewed: None

2023-01-27 13:42:34,209 root INFO Applying tag to

2023-01-27 13:42:34,209 root INFO Printing Workbook Info

Project Name: Content Migration Tool (CMT) To Demo

Workbook Name: World Indicators

Workbook ID: f058c5bd-3dde-476f-b01b-1787d935f6c1

Date Last Updated: 2021-06-11 18:10:30+00:00

Workbook Tags: set()

2023-01-27 13:42:34,209 root INFO Updated Tags List: ['StaleTag:LAST_USED_NEVER', 'source_projectName:Content Migration Tool (CMT) To Demo']

2023-01-27 13:42:34,209 tableau.endpoint DEBUG request put, url: URL/api/3.15/sites/siteid/workbooks/f058c5bd-3dde-476f-b01b-1787d935f6c1/tags

2023-01-27 13:42:34,210 tableau.endpoint DEBUG request content: b'<tsRequest><tags><tag label="StaleTag:LAST_USED_NEVER" /><tag label="source_projectName:Content Migration Tool (CMT) To Demo" /></tags></tsRequest>'

2023-01-27 13:42:34,428 urllib3.connectionpool DEBUG URL:443 "PUT /api/3.15/sites/siteid/workbooks/f058c5bd-3dde-476f-b01b-1787d935f6c1/tags HTTP/1.1" 200 282

2023-01-27 13:42:34,430 tableau.endpoint DEBUG Server response from URL/api/3.15/sites/siteid/workbooks/f058c5bd-3dde-476f-b01b-1787d935f6c1/tags:

<ns0:tsResponse xmlns:ns0="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_15.xsd"><ns0:tags><ns0:tag label="(CMT)" /><ns0:tag label="Demo" /><ns0:tag label="Migration" /><ns0:tag label="StaleTag:LAST_USED_NEVER" /><ns0:tag label="To" /><ns0:tag label="Tool" /><ns0:tag label="source_projectName:Content" /></ns0:tags></ns0:tsResponse>

2023-01-27 13:42:34,430 tableau.endpoint.resource_tagger INFO Updated tags to {'StaleTag:LAST_USED_NEVER', 'Tool', 'To', 'Migration', '(CMT)', 'source_projectName:Content', 'Demo'}

3 risposte
  1. 1 feb 2023, 17:42

    Updated the python code to use this style

    tags_new_list.append(str(f"\'\"source_projectName:{workbook.project_name}\"\'"))

    and the results came out as expected.

    <ns0:project id="afb6c8f1-95b8-4079-bed3-1f4f7e2add94" name="Content Migration Tool (CMT) From Demo" />

    <ns0:tag label="StaleTag:LAST_USED_NEVER" />

    <ns0:tag label="source_projectName:Content Migration Tool (CMT) From Demo" />

    </ns0:tags>

0/9000