kernel_api: REDCapR internal function for calling the REDCap API

View source: R/kernel-api.R

kernel_apiR Documentation

REDCapR internal function for calling the REDCap API

Description

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

Usage

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'.

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().

Value

A utils::packageVersion.

Examples

config_options <- NULL
uri            <- "https://bbmc.ouhsc.edu/redcap/api/"
token          <- "9A81268476645C4E5F03428B8AC3AA7B"
post_body      <- list(
  token    = token,
  content  = 'project',
  format   = 'csv'
)
## Not run: 
kernel <- REDCapR:::kernel_api(uri, post_body, config_options)

# Consume the results in a few different ways.
kernel$result
read.csv(text=kernel$raw_text)
as.list(read.csv(text=kernel$raw_text))

## End(Not run)

REDCapR documentation built on Aug. 10, 2022, 5:06 p.m.