eikek / docspell

Assist in organizing your piles of documents, resulting from scanners, e-mails and other sources with miminal effort.
https://docspell.org
GNU Affero General Public License v3.0
1.57k stars 117 forks source link

import-paperless.sh fails "parse error: Invalid numeric literal at line 1, column 4" #1241

Open stepanov1975 opened 2 years ago

stepanov1975 commented 2 years ago

Hi,

I am trying to import my documents from paperless. When I run import-paperless.sh it fails with the following error: parse error: Invalid numeric literal at line 1, column 4

I am using paperless 1.5.0

Full script output:

##################### START #####################
  Docspell - Import from Paperless v '0.3 beta'
         by totti4ever

  Sun Dec 26 15:28:21 UTC 2021

#################################################

Login successfull ( Token: ... )

### documents_correspondent ###
1/5     "Irina Zonstein" [id: 90]
            parse error: Invalid numeric literal at line 1, column 4
parse error: Invalid numeric literal at line 1, column 4
parse error: Invalid numeric literal at line 1, column 4
FATAL  Error during creation of organization: 
eikek commented 2 years ago

Ah, I think the script is not updated to API changes. This line here needs to change, I think: https://github.com/eikek/docspell/blob/cff2321ecacaa1bcfc5e75f2d72faf5c90bf35d5/tools/import-paperless/import-paperless.sh#L145

The current api for creating a new organization is here: https://docspell.org/openapi/docspell-openapi.html#operation/sec-org-new

I think we need to add additional data to the json payload. Can you try to add "shortName":"", "use":"correspondent" to the json data in that line (after "created":0)?

stepanov1975 commented 2 years ago

@eikek thanks for the replay I changed line 145 to look like this:

curl_call "-s -X POST '$ds_url/api/v1/sec/organization' -H 'Content-Type: application/json' -d '{\"id\":\"\",\"name\":\"${tmp_result_arr[name]}\",\"address\":{\"street\":\"\",\"zip\":\"\",\"city\":\"\",\"country\":\"\"},\"contacts\":[],\"created\":0,"shortName":"","use":"correspondent"}'"

I am still getting the same error It seems the error is during parsing of the Paperless database

eikek commented 2 years ago

Yes, that is also an option! I thought the error was given by jq (when reading invalid json). Unfortunately I can't test this script myself so I'm not of good help :/ I think I would try looking into some variables near this place; and maybe playing with that curl command manually. The script was written some time ago, it may be not up to date with respect to the paperless data model and also docspells api. You can also watch the restserver logs when this script is running. It should mention invalid requests, for example.

stepanov1975 commented 2 years ago

@eikek Although I do some programming, I just don't have time to dig into both programs to fix the script. I hope you will find some time :) I have a lot of documents in Paperless.

eikek commented 2 years ago

Hi @stepanov1975 sure, fair enough. I don't use paperless and don't have it installed. So I won't be able to fix it. I'll add a note to the docs that it doesn't work right now. Maybe someone with paperless can look into it at some point.