Changing Access Types in Updated connectapi

Hello!

I've spent some time looking through documentation and can't quite find the answer to this question.

In earlier versions of RSC and connectapi, I was able to create an app and update the access type to "all" doing the following:

    myapp <- connectapi::deploy(client, bnd)
    myapp$update(access_type = 'all')

This throws an error now. Is there an updated function/place to update that I'm missing/can't find?

Thanks!

connectapi version: 0.1.0.9020
RSC version: 1.7.8-7

Hello @davisderodes ! And welcome to the community!

Apologies for the trouble! You are right - in 0.1.0.9018, we switched myapp$update() to use a PATCH verb (which was added in 1.8.6) :frowning:

Double unfortunately, we do not clearly tag our versions (yet) :see_no_evil: In any case, I used git blame to track back to when we bumped to 0.1.0.9017, which was here: 44afb9519aad08524b7bd162bc778355aa54dfa0

So the following may get you resolved?

remotes::install_github("rstudio/connectapi@44afb9519a")

Alternatively, you can look at the source from that version:

(Although ugh.. it looks like we may not have kept close eye on our versions :grimacing: )

And issue your own myapp$get_connect()POST() using the old pattern.

This is the source from the old version:

   update = function(...) {
     params <- rlang::list2(...)
     url <- glue::glue("v1/experimental/content/{self$get_content()$guid}")
     res <- self$get_connect()$POST(
       url,
       params
     )
     return(self)
   },

Apologies for the trouble! I definitely recommend updating Connect when you get a chance - lots of good new APIs to work with!! (Although we are a bit behind implementing them in connectapi, to be honest :see_no_evil: )

Hey Cole! No problem! Thanks for your prompt response.

I knew downloading an older version of connectapi would also solve the issue (so thank you for pointing me in the right direction to download it!)

Thanks!

1 Like

Hey Cole,

I think I might've gotten too cocky that it would work. I'm still having the same issue, but I do think downloading an older version should work.

Is there an even older version? (I know version .9011 worked back with R 3.6.2)

Thanks!

I actually think it might be easier to just extend the Content object until you can update to a newer version of RStudio Connect. To be honest, perhaps we should have done this for some level of backwards compatibility anyways (sorry about that :sweat_smile: ).

This way, you get to keep bug fixes, new features and the like while getting functional updates to the old server install.

Content2 <- R6::R6Class(
  "Content2",
  inherit = connectapi::Content,
  public = list(
    update2 = function(...) {
      params <- rlang::list2(...)
      url <- glue::glue("v1/experimental/content/{self$get_content()$guid}")
      res <- self$get_connect()$POST(
        url,
        params
      )
      return(self)
    }
  )
)


client <- connect()
my_guid <- "13e5c111-8229-4638-a62d-011f776b7443"
myc <- Content2$new(connect = client, content = client$content(my_guid))

myc$update2(access_type = 'all')

Alternatively, you can craft the request manually (less code :grinning_face_with_smiling_eyes: ):

client <- connect()
my_guid <- "13e5c111-8229-4638-a62d-011f776b7443"
myc <- content_item(client, my_guid)

the_url <- glue::glue("v1/experimental/content/{my_guid}")
myc$get_connect()$POST(the_url, list(access_type = 'all'))

Does that help? I have tested this on a recent version of Connect and it seems to work! Hopefully it will work for you now :grimacing:

Sorry for the hilariously late response. But the less code version works fantastic. Thank you so much.

1 Like