我正在使用redcap API尝试将文件上传到数据访问组内的文件存储库中:
library(RCurl)
#!/usr/bin/env Rscript
token <- "xyz123456"
url <- "https://redcap.myredcap/api/"
file <- '//example/my_directory/file_example.html'
formData <- list("token"=token,
action='import',
content='fileRepository',
folder_id=1,
returnFormat='json',
file=file
)
response <- httr::POST(url, body = formData, encode = "multipart")
result <- httr::content(response)
print(result)
字符串
获取此错误:
$error
[1] "No valid file was uploaded"
型
任何帮助赞赏!
1条答案
按热度按时间m1m5dgzv1#
尝试将
file = file
替换为file = httr::upload_file(file)
-当我直接将文件上传到RC时,这对我很有效(尽管难以复制,但我只是在我的一个项目上测试了它,它工作了(虽然不是特定于DAG,但代码中唯一的区别是我没有folder_id = 1
):字符串