I'm using Stata to get files that are in file repository in redcap but i can't do it. I have two files in the folder "test" in my file repository and i want to import them.
I am trying this :
shell `curlpath' ///
--form token=`apitoken' ///
--form content=fileRepository ///
--form action=list ///
--form format=csv ///
--form folder_id=4 ///
--form returnFormat=csv ///
`apiurl'
but it doesn't work, do you know why?
Thanks !
You have a couple of things going on here that you'll need to change.
First, you're using the list
action, which is going to return a csv string (because you've used format=csv
) of files in the folder. That will actually be a little useful, because it will give you the document IDs you need to actually get your files.
To get your files, you need to use action=export
and then you'll need to replace folder_id
with doc_id
and use the document ID of the file you want to pull out of the repository.
The API method only pulls one file at a time, so you will need to make a separate call for each file.
shell `curlpath' ///
--form token=`apitoken' ///
--form content=fileRepository ///
--form action=export ///
--form doc_id=[1234] ///
--form returnFormat=csv ///
`apiurl'