Deleting Vanity URLs
Problem
You want to delete the Vanity URL assigned to your Content.
Solution
Requires posit-sdk>=0.6.0
Obtain the content
object for your Content. In this example, we get the Content using its GUID.
from posit import connect
= connect.Client()
client
= "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
= client.content.get(CONTENT_GUID) content
Then delete the content.vanity
attribute to destroy the Vanity URL.
del content.vanity
Obtain the content
object for your Content. In this example, we get the Content using its GUID. Then call delete_vanity_url
to delete the Vanity URL.
library(connectapi)
<- connect()
client
<- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
CONTENT_GUID
<- content_item(client, CONTENT_GUID)
content delete_vanity_url(content)
A successful response prints the following output.
:
Posit Connect Content: 154bd2af-e8fa-4aa4-aab8-dcef701f4af9
Content GUID: https://rsc.radixu.com/connect/#/apps/154bd2af-e8fa-4aa4-aab8-dcef701f4af9/
Content URL: Example Content
Content Title
content_item(client, guid = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9")
Discussion
If you are working with the vanity
object you can also call the destroy
method to delete the Vanity URL.
>>> vanity = content.find_vanity()
>>> vanity.destroy()
Note that if you have previously accessed the content.vanity
attribute, a copy of the Vanity
object is cached in-memory. Calling destroy
directly will not unload the cached instance. You must call the content.reset_vanity
method to unload it.
>>> content.reset_vanity()