apiCall
is a wrapper for attempting to access the
API via httr::POST
, and then via RCurl::postForm
if a
particular error occurs. This prevents a particular kind of error for
which I haven't found a proper solution, but at least allows the
expected behavior of the package. Since writing this, I have found
a solution to set the config option encoding='identity'
. I
may remove this function at some point in the future.
apiCall(url, body, config)
URL of the REDCap API
List of parameters to be passed to httr::POST
's
body
argument or RCurl::postForm
's .param
argument.
A list of options to be passed to httr::POST
's
config
argument or RCurl::postForm
's .opts
argument.
Benjamin Nutter
Somewhere in the middle of an upgrade to RStudio, R 3.1.1, and
various other system changes, I began seeing the error
'GnuTLS recv error (-9): A TLS packet with unexpected length was received.'
I still don't know what this error means, but it only occurs when using
httr
on Linux. The RCurl
equivalents appear to work just fine.
In order to prevent this error from occurring, and making the package
rather useless, apiCall
wraps httr::POST
into a
tryCatch
call. If the GnuTLS error is thrown, apiCall
then resorts to using the RCurl
equivalent call.
Since originally writing this function, I've determined that the problem
occurs due to weird characters being exported from REDCap that cannot be
properly escaped in R. It can be resolved by using the config option
encoding = 'identity'
. Making this a default could make this
function unnecessary.
Please refer to your institution's API documentation.
Additional details on API parameters are found on the package wiki at https://github.com/nutterb/redcapAPI/wiki/REDCap-API-Parameters