Deleting Vanity URLs

Problem

You want to delete the Vanity URL assigned to your Content.

Solution

Note

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

client = connect.Client()

CONTENT_GUID = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"

content = client.content.get(CONTENT_GUID)

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)
client <- connect()

CONTENT_GUID <- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"

content <- content_item(client, CONTENT_GUID)
delete_vanity_url(content)

A successful response prints the following output.

Posit Connect Content:
  Content GUID: 154bd2af-e8fa-4aa4-aab8-dcef701f4af9
  Content URL: https://rsc.radixu.com/connect/#/apps/154bd2af-e8fa-4aa4-aab8-dcef701f4af9/
  Content Title: Example Content

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()
Warning

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()