Viewing a Content Item’s Vanity URL
Problem
You need to get the vanity URL for a content item.
Solution
Use the unique identifier (GUID) of the content item to look up its vanity URL.
from posit import connect
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
= connect.Client()
client
= client.get(f"/v1/content/{CONTENT_GUID}/vanity").json() vanity
The resulting object is a JSON dictionary with information on the vanity URL.
>>> vanity
'content_guid': '154bd2af-e8fa-4aa4-aab8-dcef701f4af9',
{'path': '/my-vanity-url/',
'created_time': '2024-04-25T18:27:16Z'}
library(connectapi)
<- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
<- connect()
client
<- content_item(client, CONTENT_GUID)
content <- get_vanity_url(content) vanity
The get_vanity_url()
function returns a character vector containing the vanity URL.
> vanity
1] "/my-vanity-url/" [