Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/500 error when using csv_import API call #907

Open
frenzymadness opened this issue Oct 26, 2023 · 5 comments
Open

HTTP/500 error when using csv_import API call #907

frenzymadness opened this issue Oct 26, 2023 · 5 comments
Labels
low priority To be done later

Comments

@frenzymadness
Copy link

Description

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.

Steps to Reproduce

  1. Create a form.
  2. Add a response to it.
  3. Use API to export a CSV from it. Something like curl -v -X GET https://kc.kobotoolbox.org/api/v1/forms/XXX.csv
  4. Remove the response from the form data to prevent duplicates (probably an optional step)
  5. Use API to import previously exported CSV back. Something like curl -v -X POST https://kc.kobotoolbox.org/api/v1/forms/XXX/csv_import -u "user:pass" -F csv_file=@/home/user/XXX.csv

Expected behavior

Import is successful and if there is an error in the imported data, a meaningful error message is returned by the API.

Actual behavior

HTML page with HTTP/500 error.

Additional details

I need to import a few hundred of responses from our previous system so I wanted to learn about the structure of the CSV file expected by the kobo toolbox for the given form so I thought that the simple export/import should work. Is there any documentation of what should be in the CSV file one wants to import? It's obvious for responses to the questions from the form but less obvious for columns like _id or _uuid.

@frenzymadness
Copy link
Author

I've might found the code handling this in:

I've tried to create a minimal reproducer, but the following lines work fine with the exported file:

>>> import unicodecsv as ucsv
>>> csv_file = open("XXX.csv", mode="rb")
>>> csv_reader = ucsv.DictReader(csv_file)
>>> for row in csv_reader:
...   print(row)
...

@noliveleger
Copy link
Contributor

Hello @frenzymadness,

This issue is related to Kobocat and API v1 which has been deprecated for a while.
Please open an issue there https://github.com/kobotoolbox/kobocat/ and close this one.
TBH, the error may not be fixed (since the API is deprecated) or will be considered a (very) low priority and may take a while.

Due to the small size of our team and large volume of users, we cannot provide support or guidance via GitHub issues.
Please use the community forum to seek for help.

@frenzymadness
Copy link
Author

Thank you very much for the response. I had a discussion about this on the community forum and it seems that csv import is really not functioning properly now. What is kinda confusing to me is that if v1 of API is deprecated, where I can find documentation for v2? When I try to visit https://kc.kobotoolbox.org/api/v2/ it redirects me back to v1 and there id no notice about it being deprecated.

@noliveleger
Copy link
Contributor

API v2 is located at https://kf.kobotoolbox.org/api/v2/ (different domain name)

@jnm jnm closed this as completed Nov 24, 2023
@jnm jnm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2023
@jnm jnm transferred this issue from kobotoolbox/kpi Nov 24, 2023
@jnm jnm reopened this Nov 24, 2023
@jnm
Copy link
Member

jnm commented Nov 24, 2023

I've transferred the issue to the appropriate repository.

@jnm jnm added the low priority To be done later label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority To be done later
Projects
None yet
Development

No branches or pull requests

3 participants