redcap_write_oneshot() takes too long to run in R

Re: redcap_write_oneshot() takes too long to run in R

par Corentin Aurèle Wicht,
Nombre de réponses : 0
Dear Hugo,

Unfortunately, the RedcapR::redcap_write_oneshot() function can only import the whole database (and not specific fields), which may be very slow in cases where the database is large.

Here is an alternative solution:

If you go under  then select  you will find at the bottom of the page: .

You can then open the "import_records.R" file and adapt it to your database and field names, as such:

library(RCurl)
library(jsonlite)

# Record ID(s)
record_id = 2

# API infos
api_token <- "YOURAPITOKEN"
api_url <- "https://redcapmed.unifr.ch/api/"

# Database of modifications to import in REDCap (field names)
record <- c(
record_id=record_id,
sql_tag=1)

# Convert to JSON
data <- jsonlite::toJSON(list(as.list(record)), auto_unbox=TRUE)

# Import in REDCap
result <- RCurl::postForm(
api_url,
token=api_token,
content='record',
format='json',
type='flat',
data=data
)
Best wishes,

C.

124 mots