Skip to content

Commit 12002e6

Browse files
committed
parameterize encoding and handle passed to httr::POST()
@brandonpotvin, glad the last one worked. Love to be wrong. Will you give this commit a shot? Notice I renamed to `handle_httr` and also added `encode_httr` that you should set to "form". ref #429
1 parent 4526179 commit 12002e6

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

R/kernel-api.R

+14-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
#' to 'UTF-8'.
1717
#' @param content_type The MIME value passed to [httr::content()]. Defaults
1818
#' to 'text/csv'.
19+
#' @param handle_httr The value passed to the `handle` parameter of
20+
#' [httr::POST()].
21+
#' This is useful for only unconventional authentication approaches. It
22+
#' should be `NULL` for most institutions.
23+
#' @param encode_httr The value passed to the `encode` parameter of
24+
#' [httr::POST()].
25+
#' This is useful for only unconventional authentication approaches.
26+
#' Defaults to `"multipart"`, which is appropriate for most institutions.
1927
#'
2028
#' @return
2129
#' A [utils::packageVersion].
@@ -50,12 +58,14 @@ kernel_api <- function(
5058
config_options,
5159
encoding = "UTF-8",
5260
content_type = "text/csv",
53-
cdc_handle = NULL
54-
) {
61+
handle_httr = NULL,
62+
encode_httr = "multipart"
63+
) {
5564

5665
checkmate::assert_character(redcap_uri , len = 1, any.missing = FALSE, null.ok = FALSE)
5766
checkmate::assert_character(encoding , len = 1, any.missing = FALSE, null.ok = FALSE)
5867
checkmate::assert_character(content_type , len = 1, any.missing = FALSE, null.ok = FALSE)
68+
checkmate::assert_character(encode_httr , len = 1, any.missing = FALSE, null.ok = FALSE)
5969

6070
start_time <- Sys.time()
6171

@@ -67,8 +77,8 @@ kernel_api <- function(
6777
url = redcap_uri,
6878
body = post_body,
6979
config = config_options,
70-
handle = cdc_handle,
71-
encode = "form",
80+
handle = handle_httr,
81+
encode = encode_httr,
7282
httr::user_agent("OuhscBbmc/REDCapR")
7383
)
7484

R/redcap-read-oneshot.R

+13-2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@
8585
#' be visible somewhere public. Optional.
8686
#' @param config_options A list of options passed to [httr::POST()].
8787
#' See details at [httr::httr_options()]. Optional.
88+
#' @param handle_httr The value passed to the `handle` parameter of
89+
#' [httr::POST()].
90+
#' This is useful for only unconventional authentication approaches. It
91+
#' should be `NULL` for most institutions.
92+
#' @param encode_httr The value passed to the `encode` parameter of
93+
#' [httr::POST()].
94+
#' This is useful for only unconventional authentication approaches.
95+
#' Defaults to `"multipart"`, which is appropriate for most institutions.
8896
#'
8997
#' @return
9098
#' Currently, a list is returned with the following elements:
@@ -195,7 +203,8 @@ redcap_read_oneshot <- function(
195203
locale = readr::default_locale(),
196204
verbose = TRUE,
197205
config_options = NULL,
198-
cdc_handle = NULL
206+
handle_httr = NULL,
207+
encode_httr = "multipart"
199208
) {
200209

201210
checkmate::assert_character(redcap_uri , any.missing=FALSE, len=1, pattern="^.{1,}$")
@@ -228,6 +237,7 @@ redcap_read_oneshot <- function(
228237
checkmate::assert_class( locale, "locale" , null.ok = FALSE)
229238
checkmate::assert_logical( verbose , any.missing=FALSE, len=1, null.ok=TRUE)
230239
checkmate::assert_list( config_options , any.missing=TRUE , null.ok=TRUE)
240+
checkmate::assert_character(encode_httr , any.missing=FALSE, len=1, null.ok = FALSE)
231241

232242
validate_field_names(fields, stop_on_error = TRUE)
233243

@@ -273,7 +283,8 @@ redcap_read_oneshot <- function(
273283
post_body = post_body,
274284
config_options = config_options,
275285
encoding = http_response_encoding,
276-
cdc_handle = cdc_handle
286+
handle_httr = handle_httr,
287+
encode_httr = encode_httr
277288
)
278289

279290
if (kernel$success) {

man/kernel_api.Rd

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/redcap_read_oneshot.Rd

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)