Since RStudio Connect 1.9.0, the URL string for applications hosted on RStudio Connect changed from displaying the Application ID to the GUID. Some administrators have reported the need to retain the ability to locate apps by their internal ID. Administrators can use the RStudio Connect Content API to view and manage content for applications hosted on Connect, including the GUID and Application IDs. This document serves as a guide for systems administrators who are hoping to find specific application information using the Connect API.
Note: The RStudio Connect API requires an appropriate license, please contact your Customer Success Rep if you are unsure if this is available.
Generate the API Key
API keys can be found in the Connect dashboard and are organized according to usernames.
Note: to use the Connect Content API, the API key will need to be generated from a user with the Admin role.
Login to the RStudio Connect dashboard and navigate to People —> Users —> <Your Username>. Underneath the user profile click on “API Keys” and then “New API Key”. Finally, give the API Key a name, enter user credentials and save your API key somewhere safe.
Create an .Renviron File
From the Workbench or Desktop IDE instance, open the terminal and execute the below steps.
Please note: In RStudio Workbench you will need to have permission to edit the .Renviron file.
In the home folder of the user that will run the API code, execute the below:
$ sudo touch .Renviron
$ sudo vim .Renviron
#The CONNECT_SERVER URL must have a trailing slash.
After this is completed, save the file and then restart the R Session in the IDE. This can be done by going to Session —> Restart R
Create the Script
In the IDE, create an R script file (File —> New File —> R Script) with the below contents and run the entire block.
title: "Get Content List"
connectServer <- Sys.getenv("CONNECT_SERVER")
apiKey <- Sys.getenv("CONNECT_API_KEY")
result <- GET(paste0(connectServer, '__api__/v1/content'),
add_headers(Authorization = paste("Key", apiKey)))
The output will then be displayed like the below:
The script output contains both the ID and the GUID for each application. Systems administrators can use the RStudio Connect Content API to generate this information, along with other useful data points such as timestamps and specific application process settings. That information can then be used to parse through server data related to RStudio Connect applications or given to the RStudio Support team if needed.