PyCap: import_file does not work in REDCap 7.4.23
I cannot make the file_import to work, working with a server running REDCap 7.4.23.
I followed the example from http://pycap.readthedocs.io/en/latest/deep.html#working-with-files, but it fails with HTTPError: 400 Client Error: Bad Request for url.
Interestingly, it fails also from REDCap’s API playground, but I managed to import the file using curl from the command line (in linux).
I have just started with REDCap, so I do not know how this worked on earlier versions
I have also noticed that the REDCap documentation for the import API does not have a parameter for file name (and, indeed, it gets ignored when using curl), but has an additional parameter repeat_instance, needed to upload a file to repeating instruments.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16
Yes: Lazy=False did the trick … The following works fine 😃
#ghrc01 - GitHubRedCap #WinServer2012/Anaconda3/Python 3.7.3/pip PyCap 0.0.0/REDCap 8.10.7/ from redcap import Project api_url = 'https://www.example.com/redcap/api/' api_key = '********' project = Project(api_url,api_key,verify_ssl=False,lazy=False) print('-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*') record = 'RECORD' field = 'file' fname = 'test.txt' with open(fname,'r') as fobj: rf = project.import_file(record,field,fname,fobj) print(rf) print('-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*')H:\py>python -W ignore ghrc01.py -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* {} -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*I’m noticing the
verify=Falsearg in your POST request. If you create a project withProject(URL, TOKEN, verify_ssl=False)does the file import work?