Issues with csv import


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 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 -u "user:pass" -F csv_file=@/home/user/XXX.csv.

The response contains somewhere in the middle:

	500 Error

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.

Hello @frenzy and welcome to the community!

The api endpoint has changed to v2 in the recent update:

You might want to update the API call accordingly.

1 Like

Thank you very much for the response. When I try to open API v2, for example it redirects me to

Response from curl:

< HTTP/2 302 
< date: Thu, 26 Oct 2023 15:59:18 GMT
< content-type: text/html; charset=utf-8
< content-length: 0
< server: nginx
< location: /api/v1/

Where I can find documentation for API v2, please?

Hi @frenzy working with CSV is little bit tricky in Kobo, I suggest you focus on JSON import, you can do it easier and find examples in the community.

APV v2 documentation is not complete, it is here and there, you need to read all existing ones and complete missing part by little bit guess

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”.

Is there any way how to solve this issue?

@frenzy, you will need to use the following API for V2:

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


1 Like