I’m trying to import some data to an existing form and the response I’m getting from API is HTTP/500 with full HTML content which is not expected from an API.
I wanted to try it in a very simple way so I added a single response to the existing form, used API call curl -v -X GET https://kc.kobotoolbox.org/api/v1/forms/XXX.csv to get the data and then I removed the single response from the form via web UI and then I tried to import the CSV back via curl -v -X POST https://kc.kobotoolbox.org/api/v1/forms/XXX/csv_import -u "user:pass" -F csv_file=@/home/user/XXX.csv.
The response contains somewhere in the middle:
The questions are:
what I’m doing wrong?
what is the expected format for CSV files for import? The export contains some hidden fields like _id and _uuid and I’m not sure what to put there when I create an import from a different system.
is there any other way I can try to export/import data from previous systems?
Thank you very much for any help. We have hundreds of responses to migrate and we don’t want to add them manually.
Thank you all for your help. I’ve found the thread pointing to the video describing how I can do it with JSON.
But there is another issue. It seems that when I export data with submissions where questions are split into groups, I cannot import them back. Let’s say I’m asking for an e-mail address in a group of questions called respondent. The column in the data table has “group_respondent / E_mail” in the header. I can see the same column when I export data into CSV and then I transfer them into JSON, the key “group_respondent/E_mail” is still there. Then, I use API to import that record back and it seems that the import normalizes the groups delimiter and there is a new column after the import called “group_respondent_E_mail”.
Hi again, you found my video, that’s good. So there is part that missing in the video, the inital form i used did not have groups so i didn’t add it. Here what you need to do if there is a group question,
You need to adjust the code little bit, you neee to group by all question under a group, you can use the example code below