This function is used by other functions to read and write values.

kernel_api(
  redcap_uri,
  post_body,
  config_options,
  encoding = "UTF-8",
  content_type = "text/csv"
)

Arguments

redcap_uri

The URI (uniform resource identifier) of the REDCap project. Required.

post_body

List of contents expected by the REDCap API. Required.

config_options

A list of options to pass to POST method in the httr package. See the details below. Optional.

encoding

The encoding value passed to httr::content(). Defaults to 'UTF-8'.

content_type

The MIME value passed to httr::content(). Defaults to 'text/csv'.

Value

A utils::packageVersion.

Details

If the API call is unsuccessful, a value of base::package_version("0.0.0") will be returned. This ensures that a the function will always return an object of class base::package_version. It guarantees the value can always be used in utils::compareVersion().

Examples

config_options <- NULL uri <- "https://bbmc.ouhsc.edu/redcap/api/" token <- "9A81268476645C4E5F03428B8AC3AA7B" post_body <- list( token = token, content = 'project', format = 'csv' ) kernel <- REDCapR:::kernel_api(uri, post_body, config_options) # Consume the results in a few different ways. kernel$result
#> Response [https://bbmc.ouhsc.edu/redcap/api/] #> Date: 2020-09-27 22:39 #> Status: 200 #> Content-Type: text/csv; charset=utf-8 #> Size: 557 B #> project_id,project_title,creation_time,production_time,in_production,project_... #> 153,"REDCapR Target Simple Static -see https://github.com/OuhscBbmc/REDCapR",...
read.csv(text=kernel$raw_text, stringsAsFactors=FALSE)
#> project_id #> 1 153 #> project_title #> 1 REDCapR Target Simple Static -see https://github.com/OuhscBbmc/REDCapR #> creation_time production_time in_production project_language purpose #> 1 2013-11-29 15:58:20 NA 0 English 0 #> purpose_other project_notes custom_record_label secondary_unique_field #> 1 NA NA NA NA #> is_longitudinal surveys_enabled scheduling_enabled #> 1 0 0 0 #> record_autonumbering_enabled randomization_enabled ddp_enabled #> 1 1 0 0 #> project_irb_number project_grant_number project_pi_firstname #> 1 NA NA NA #> project_pi_lastname display_today_now_button #> 1 NA 1 #> has_repeating_instruments_or_events #> 1 0
as.list(read.csv(text=kernel$raw_text, stringsAsFactors=FALSE))
#> $project_id #> [1] 153 #> #> $project_title #> [1] "REDCapR Target Simple Static -see https://github.com/OuhscBbmc/REDCapR" #> #> $creation_time #> [1] "2013-11-29 15:58:20" #> #> $production_time #> [1] NA #> #> $in_production #> [1] 0 #> #> $project_language #> [1] "English" #> #> $purpose #> [1] 0 #> #> $purpose_other #> [1] NA #> #> $project_notes #> [1] NA #> #> $custom_record_label #> [1] NA #> #> $secondary_unique_field #> [1] NA #> #> $is_longitudinal #> [1] 0 #> #> $surveys_enabled #> [1] 0 #> #> $scheduling_enabled #> [1] 0 #> #> $record_autonumbering_enabled #> [1] 1 #> #> $randomization_enabled #> [1] 0 #> #> $ddp_enabled #> [1] 0 #> #> $project_irb_number #> [1] NA #> #> $project_grant_number #> [1] NA #> #> $project_pi_firstname #> [1] NA #> #> $project_pi_lastname #> [1] NA #> #> $display_today_now_button #> [1] 1 #> #> $has_repeating_instruments_or_events #> [1] 0 #>