Viewing Tags by Content
Problem
You want to view what tags are assigned to a particular content item.
Note
To learn how to find all content by that has a particular tag assigned, see Finding Content by Tag.
Solution
A content item identifier is required to find tags.
from posit import connect
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
= connect.Client()
client
= client.get(f"/v1/content/{CONTENT_GUID}/tags") res
The API response can be transformed into a data frame for easy viewing.
>>> import polars as pl
>>> pl.DataFrame(res.json())
2, 5)
shape: (
┌─────┬───────────────────────────┬───────────┬──────────────────────┬──────────────────────┐id ┆ name ┆ parent_id ┆ created_time ┆ updated_time │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str ┆ str ┆ str │
│
╞═════╪═══════════════════════════╪═══════════╪══════════════════════╪══════════════════════╡4 ┆ Software ┆ 1 ┆ 2017-04-18T19:54:24Z ┆ 2017-05-19T18:15:39Z │
│ 751 ┆ Artificial Intelligence ┆ 736 ┆ 2017-04-18T19:54:32Z ┆ 2017-05-03T20:15:27Z │
│ └─────┴───────────────────────────┴───────────┴──────────────────────┴──────────────────────┘
The get_content_tags()
function returns a tag tree object for the provided content item.
library(connectapi)
<- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
<- get_content(client, guid = CONTENT_GUID)
target_content <- get_content_tags(target_content) tags
get_content_tags()
returns a tag tree object.
> tags
Tree (content)
Posit Connect Tag
└── Departments └── Administrative