Connect API deleted content issue

I've noticed that deleted content seems to cause a problem with gathering up the document details from the API endpoint. The content guid exists in instrumentation/content, but isn't found in experimental/content. Perhaps some error handling can be added to the get_content and get_content_name helper functions referenced by the rsc-usage.Rmd (https://github.com/sol-eng/connect-usage)?

Here's an error below for a content guid that we deleted.

Error in sprintf("experimental/content/%s", content_guid) :
argument "content_guid" is missing, with no default

Thanks for the note! That is a great call and is not something that we took into account for that example. We will definitely make a note to improve the example to be more portable in that way!

No worries! The document you posted it on Github has been very helpful. We've published it to our server pretty much as is.

Below is our temporary fix for the deleted content if you're interested.

# get content by guid
get_content <- function(content_guid) {
  tryCatch({resp <- connect_api(sprintf("experimental/content/%s", content_guid))
           httr::content(resp)}, error = function(e) 'Unknown (Deleted Content?)')
  
}

get_content_name <- function(content_guid) {
  tryCatch({content <- get_content(content_guid)
  null_char(content$title, content$name)},error = function(e) 'Unknown (Deleted Content?)')
}
1 Like

We're so glad to hear that it has been helpful! Thanks for the note on the fix as well. Feel free to contribute on GitHub or share any improvements that you make to the code here on Community, if you'd like! I'm sure there will be many more users who will be interested in more detailed / granular reporting on this data.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.