The record event name cannot be empty error
Closed this issue · 1 comments
KirstieJane commented
Here's the code I wrote (after setting up my data_dir, api_url and api_url variables)
os.environ['SUBJECTS_DIR'] = data_dir
from recon_stats import Subject
s = Subject('22186') # where SUBJECTID is in your SUBJECTS_DIR
# load measures
s.get_measures()
# produce a dictionary
data = s.upload_dict()
# Then using pycap, upload the data quickly
from redcap import Project
p = Project(api_url, api_key)
data[p.def_field] = '22186' # or however this subject is indexed in your REDCap
response = p.import_records([data])
Everything runs until the last step, and then I see the following error messages:
---------------------------------------------------------------------------
RequestException Traceback (most recent call last)
<ipython-input-46-de5fe1bfb267> in <module>()
15 data[p.def_field] = '22186' # or however this subject is indexed in your REDCap
16
---> 17 response = p.import_records([data])
C:\Users\Kirstie\Anaconda\lib\site-packages\pycap-0.9-py2.7.egg\redcap\project.pyc in import_records(self, to_import, overwrite, format, return_format, return_content, date_format)
420 response = self._call_api(pl, 'imp_record')[0]
421 if 'error' in response:
--> 422 raise RedcapError(str(response))
423 return response
424
RequestException: {u'error': u'The record event name cannot be empty'}
I'm sure it means that the record event name cannot be empty but I'm not quite sure where to look to input that info. If I open Redcap I can see the Freesurfer Reconstruction Stats instrument and that the event name is "Baseline Assessment Day (Arm 1: Prototype 20121019)" but I'm not sure where to fit that into the code above.
KirstieJane commented
After a wonderfully timed tweet from @sburns I added in a redcap_event_name to the upload data dictionary:
data['redcap_event_name'] = p.events[2]['unique_event_name']
before running
response = p.import_records([data])
which fixed the RequestException.