OuhscBbmc/REDCapR

Feature request: add repeat instances to redcap_upload_file_oneshot

jrob95 opened this issue · 2 comments

jrob95 commented

Hi there, just some queries about redcap_upload_file_oneshot

What happens when you upload a file to a repeating instance? I noticed that redcap_download_file_oneshot has an option to specify repeating instance. Would that be possible here?

Kind regards,
Jack

Hello, I have the same request, it is important to be able to upload files in different instances.

I have tried adding the repeat_instrument and repeat_instance arguments as in the case of redcap_download_file_oneshot but it does not recognize them.

Error in REDCapR::redcap_file_upload_oneshot(file_name = "1729606165286.jpg", : unused arguments (repeat_instrument = "datos_sensibles", repeat_instance = 5)

I worked directly with the REDCap API and added the same repeat_instrument and repeat_instance arguments to the bodyform and uploaded the file to the specific instance.

token <- Sys.getenv("token_protocol")
url <- "#######################"
file <- '1729606165286.jpg'
formData <- list("token"=token,
                 action='import',
                 content='file',
                 record='10',
                 field='field',
                 event='baseline_visit_arm_1',
                 repeat_instrument='datos_sensibles',
                 repeat_instance='5',
                 
                 returnFormat='csv',
                 file=httr::upload_file(file)
)
response <- httr::POST(url, body = formData, encode = "multipart")
result <- httr::content(response)
print(result)

this way it worked