From e431f64ca5d9082e706b88a0af140655b2d11b77 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sat, 1 Oct 2022 18:18:16 -0500 Subject: [PATCH] change "multipart" to "form" for most cases close #436 --- R/kernel-api.R | 15 ++++++++------- R/redcap-file-upload-oneshot.R | 3 ++- man/kernel_api.Rd | 9 ++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/R/kernel-api.R b/R/kernel-api.R index 00dc0773..192292ac 100644 --- a/R/kernel-api.R +++ b/R/kernel-api.R @@ -20,10 +20,11 @@ #' [httr::POST()]. #' This is useful for only unconventional authentication approaches. It #' should be `NULL` for most institutions. -# @param encode_httr The value passed to the `encode` parameter of -# [httr::POST()]. -# This is useful for only unconventional authentication approaches. -# Defaults to `"multipart"`, which is appropriate for most institutions. +#' @param encode_httr The value passed to the `encode` parameter of +#' [httr::POST()]. +#' Defaults to `"form"`, which is appropriate for most actions. +#' (Currently, the only exception is importing a file, +#' which uses "multipart".) #' #' @return #' A [utils::packageVersion]. @@ -58,8 +59,8 @@ kernel_api <- function( config_options, encoding = "UTF-8", content_type = "text/csv", - handle_httr = NULL - # encode_httr = "multipart" + handle_httr = NULL, + encode_httr = "form" ) { checkmate::assert_character(redcap_uri , len = 1, any.missing = FALSE, null.ok = FALSE) @@ -78,7 +79,7 @@ kernel_api <- function( body = post_body, config = config_options, handle = handle_httr, - encode = "multipart", + encode = encode_httr, httr::user_agent("OuhscBbmc/REDCapR") ) diff --git a/R/redcap-file-upload-oneshot.R b/R/redcap-file-upload-oneshot.R index c2aa03e1..c30b4ec5 100644 --- a/R/redcap-file-upload-oneshot.R +++ b/R/redcap-file-upload-oneshot.R @@ -153,7 +153,8 @@ redcap_file_upload_oneshot <- function( redcap_uri = redcap_uri, post_body = post_body, config_options = config_options, - handle_httr = handle_httr + handle_httr = handle_httr, + encode_httr = "multipart" # Uploading a file is a rare occasion doesn't use "form" ) if (kernel$success) { diff --git a/man/kernel_api.Rd b/man/kernel_api.Rd index 9ba03200..a54b3daa 100644 --- a/man/kernel_api.Rd +++ b/man/kernel_api.Rd @@ -10,7 +10,8 @@ kernel_api( config_options, encoding = "UTF-8", content_type = "text/csv", - handle_httr = NULL + handle_httr = NULL, + encode_httr = "form" ) } \arguments{ @@ -35,6 +36,12 @@ to 'text/csv'.} \code{\link[httr:POST]{httr::POST()}}. This is useful for only unconventional authentication approaches. It should be \code{NULL} for most institutions.} + +\item{encode_httr}{The value passed to the \code{encode} parameter of +\code{\link[httr:POST]{httr::POST()}}. +Defaults to \code{"form"}, which is appropriate for most actions. +(Currently, the only exception is importing a file, +which uses "multipart".)} } \value{ A \link[utils:packageDescription]{utils::packageVersion}.