While I can get this script to work just fine (it imports a file into a file repository in a REDCap project), it fails to overwrite the existing file.
library(redcapAPI)
file <- 'C:/Temp/my_report.html'
rcon <- redcapConnection(token="xyz",url = 'https://redcap.project.website/api/')
importToFileRepository(
rcon,
file,
folder_id = 1,
overwrite = TRUE,
)
Am I missing something? I would think overwrite=TRUE
would overwrite the file, but it does not.
I can understand why you would want and/or expect this behavior. Unfortunately, the REDCap doesn't support an
overwrite
argument in its API method. Consequently,importToFileRepository
doesn't support anoverwrite
argument.It would be possible to mimic this behavior by writing a separate function that exports the contents of the File Repository folder, looks for a file of the same file name, and if one exists, captures the document ID to delete after importing the new file.
I'm pseudocoding this, so please don't expect it to work out of the box, but something like
If you have a GitHub account, you can submit an issue at https://github.com/vubiostat/redcapAPI/issues. These kinds of needs are pretty warmly received among their group.