doccano-client icon indicating copy to clipboard operation
doccano-client copied to clipboard

Upload file failed

Open ChiLynn123 opened this issue 5 years ago • 1 comments

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, "csv", "data_xa.csv", "D:\WPSCloud")

error: Traceback (most recent call last): File "D:/doccano/doccano-client/doccano_api_client/example.py", line 113, in <module> r_du = doccano_client.post_doc_upload(8, "csv", "data_xa.csv", "D:\WPSCloud") File "D:\doccano\doccano-client\doccano_api_client\__init__.py", line 521, in post_doc_upload data=data File "D:\doccano\doccano-client\doccano_api_client\__init__.py", line 64, in post request_url, data=data, files=files, json=json).json() File "E:\Anaconda\lib\site-packages\requests\models.py", line 885, in json return complexjson.loads(self.text, **kwargs) File "E:\Anaconda\lib\json\__init__.py", line 354, in loads return _default_decoder.decode(s) File "E:\Anaconda\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "E:\Anaconda\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

ChiLynn123 avatar Sep 27 '20 06:09 ChiLynn123

Hi.

I get the same error when trying to upload. It seems to be the response from the API. Hope they can come up with a solution to this. :+1:

I can catch the error, and upload all my documents by doing the following:

try:
    out = client.post_doc_upload(project, 'json', name, d)
except json.decoder.JSONDecodeError:
    pass

kris927b avatar Oct 06 '20 07:10 kris927b