Post / delete media file to existing form using curl

Hi Everyone,

What is the problem? Please be detailed.
I need to do daily updates on the media file attached to a survey form (it is a csv file containing a list of names and phone numbers that change each day, but the survey form remains the same).

I can upload a form + media file at the same time with the following:
curl --verbose --digest --user UserName:Password
--header "Content-Type: multipart/form-data"
--form "form_def_file=@/Users/FILE_PATH_TO_FORM/Test.xml"
--form mediaFiles=@/Users/FILE_PATH_TO_MEDIA/comm_db.csv

But I would like to be able to:

  1. Post a media file to an existing survey form (that already contains submissions);
  2. Delete a media file that is attached to an existing survey form, without deleting the form and submissions.

What ODK tool and version are you using? And on what device and operating system version?
I am using the latest version of ODK Aggregate on Google App Engine.
My operating system is macOS 10.13.4, and I'm using iTerm2 3.1.6

What you have you tried to fix the problem?
I have tried substituting '--form_id Test' instead of
--form "form_def_file=@/Users/FILE_PATH_TO_FORM/Test.xml"

I have also tried curl DELETE, with various combinations of flags (modeled after what works for, below)

Anything else we should know or have? If you have a test form or screenshots or logs, attach here.

I currently use, and I am able to accomplish the above tasks with the following:

  1. Post a media file to existing form:
    curl -X POST -F 'data_type=media' -F 'data_value=ret_comm_db.csv' -F 'xform=FormID' -F 'data_file=@/Users/FILE_PATH_TO_MEDIA/comm_db.csv' -u UserName:Password

  2. Delete media file without deleting form:
    curl -X DELETE -u UserName:Password

Any help would be much appreciated --- thank you!!


@Nicholai_Lidow did you ever get a way around this

@Francis_Opiyo Yes!
Here is what I do:
Step 1. Post the form as a draft
curl --include
--request POST
--header 'Authorization: Basic TOKEN'
--header 'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
--header 'X-XlsForm-FormId-Fallback: FORMID'
--data-binary '@Filepath_to_XLSFORM.xlsx'
Step 2. Post attachments
curl --include
--request POST
--header 'Authorization: Basic TOKEN'
--header 'Content-Type: text/csv'
--data-binary '@/Filepath_to_Attachment'

Step 3. Publish draft with updated version number based on Sys.Time
curl --include
--request POST
--header 'Authorization: Basic TOKEN'