if (FALSE) {
# Specify your project uri and token(s).
uri <- "https://bbmc.ouhsc.edu/redcap/api/"
token_simple <- "9A81268476645C4E5F03428B8AC3AA7B"
token_longitudinal <- "0434F0E9CF53ED0587847AB6E51DE762"
# ---- Simple examples
REDCapR::redcap_project_info_read(uri, token_simple )$data
REDCapR::redcap_project_info_read(uri, token_longitudinal)$data
# ---- Specify timezone
# Specify the server's timezone, for example, US Central
server_locale <- readr::locale(tz = "America/Chicago")
d3 <-
REDCapR::redcap_project_info_read(
uri,
token_simple,
locale = server_locale
)$data
d3$creation_time
# Alternatively, set timezone to the client's location.
client_locale <- readr::locale(tz = Sys.timezone())
# ---- Inspect multiple projects in the same tibble
# Stack all the projects on top of each other in a (nested) tibble,
# starting from a csv of REDCapR test projects.
# The native pipes in this snippet require R 4.1+.
d_all <-
system.file("misc/example.credentials", package = "REDCapR") |>
readr::read_csv(
comment = "#",
col_select = c(redcap_uri, token),
col_types = readr::cols(.default = readr::col_character())
) |>
dplyr::filter(32L == nchar(token)) |>
purrr::pmap_dfr(REDCapR::redcap_project_info_read, locale = server_locale)
# Inspect values stored on the server.
d_all$data
# or: View(d_all$data)
# Inspect everything returned, including values like the http status code.
d_all
}
Run the code above in your browser using DataLab