doccano-client
doccano-client copied to clipboard
Uploading the file from the API fails
Hello, I made an error uploading the document using the API, but the document can appear in the Doccano instance database. Looking forward to your reply to my questions, thank you very much!
r_du = doccano_client.post_doc_upload(8, "json", "fail1.json", "D:\WPSCloud")
error:
Traceback (most recent call last): File "D:/doccano/doccano-client/doccano_api_client/example.py", line 113, in
Please paste an example of your file.
I can't upload a file in JSON format, Please try converting this file to JSON format.thanks very much! example.txt
I used CSV or JSON modules to generate standard CSV and JSON document invocation API interface, which also failed to upload.But this data can be seen in a database on the Web side.
Same issue here. The doccano client returns
return self.session.post(
request_url, data=data, files=files, json=json).json()
when POSTing a new document to /v1/projects/<id>/docs.
The document is created correctly (201) but the .json() throws a JSONDecodeError as the content of the response is empty, i.e. there is simply nothing to parse
@Hironsan should the API return a content from the post request /v1/projects/<id>/docs ? Or should this be fixed in the doccano client ?
Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.72. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
Hi,
I have a similar issu when trying to upload a txt file using :
doccano_client.post_doc_upload(1,'txt','input_1.txt','./')
And it returns :
simplejson.errors.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
Any update about this bug ?
Best regards,
Hi, i also have a similar issue while using post_doc_upload(), the file is correctly uploaded but it seems to crash when i try to injest it.
Following the error raised by doccano task:
[2021-06-22 13:59:58,940: INFO/MainProcess] Task api.tasks.injest_data[14eabc0b-c104-40e8-ac23-3f068f872e8b] received
[2021-06-22 13:59:58,946: ERROR/ForkPoolWorker-2] Task api.tasks.injest_data[14eabc0b-c104-40e8-ac23-3f068f872e8b] raised unexpected: Http404('No Project matches the given query.')
Traceback (most recent call last):
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/django/shortcuts.py", line 76, in get_object_or_404
return queryset.get(*args, **kwargs)
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
raise self.model.DoesNotExist(
api.models.Project.DoesNotExist: Project matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/celery/app/trace.py", line 450, in trace_task
R = retval = fun(*args, **kwargs)
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/celery/app/trace.py", line 731, in __protected_call__
return self.run(*args, **kwargs)
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/backend/api/tasks.py", line 90, in injest_data
project = get_object_or_404(Project, pk=project_id)
File "/Users/enzo/Workspace/Testing/doccano-ft/dft_env/lib/python3.9/site-packages/django/shortcuts.py", line 78, in get_object_or_404
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
django.http.response.Http404: No Project matches the given query.
Hi, same issue here
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/doccano_api_client/init.py in post_doc_upload(self, project_id, file_name, file_path, column_data, column_label, delimiter, encoding, format) 678 delimiter=delimiter, 679 encoding=encoding, --> 680 format=format, 681 ) 682
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/doccano_api_client/init.py in post_doc_upload_binary(self, project_id, files, column_data, column_label, delimiter, encoding, format) 643 "uploadIds": upload_ids, 644 } --> 645 return self.post(f"v1/projects/{project_id}/upload", json=upload_data) ... 398 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': 399 idx += 3 --> 400 return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 2 column 1 (char 1) news_test.json.zip
@Hironsan mitekudasai
When I debug the code, found the error message is
'\n<!doctype html>\n<html lang="en">\n<head>\n <title>Server Error (500)</title>\n</head>\n<body>\n <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n'