Learn R Programming

redcapAPI (version 1.1)

apiCall: Execute a Call to the REDCap API

Description

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.

Usage

apiCall(url, body, config)

Arguments

url
URL of the REDCap API
body
List of parameters to be passed to httr::POST's body argument or RCurl::postForm's .param argument.
config
A list of options to be passed to httr::POST's config argument or RCurl::postForm's .opts argument.

Details

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.

References

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