jtpio / trello-full-backup

Python script to backup everything from Trello: boards, lists, cards and attachments
MIT License
123 stars 36 forks source link

Exception JSONDecodeError #1

Open vizcay opened 8 years ago

vizcay commented 8 years ago

I get this error when I try to run the script:

Traceback (most recent call last):
  File "main.py", line 232, in <module>
    org_boards_data['me'] = requests.get(my_boards_url).json()
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 826, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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)

Any idea? thanks

jtpio commented 8 years ago

Hi,

Quickest way to debug it would be to add a print statement to display the my_board_url variable to check its value. It should be something like this: https://api.trello.com/1/members/me/boards?key=YOUR_KEY&token=YOUR_TOKEN Paste the URL in a web browser to see what you get. Could it be related to the environment variables being reset when restarting the shell?

Let me know if it helps!

rcodecom commented 6 years ago

I am getting a similar error using the docker method, and it works just fine when I insert the key and token into the URL you suggested above. Any further things I could try to fix this?

Backup initiated Backing up to: 2018-03-13_20-58-40_backup Incremental: False Tokenize: False Backup closed board: False Backup archived lists: False Backup archived cards: False Attachment size limit (bytes): 100000000

Traceback (most recent call last): File "/usr/local/bin/trello-full-backup", line 11, in sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/trello_full_backup/init.py", line 5, in main cli() File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 286, in cli org_boards_data['me'] = requests.get(my_boards_url).json() File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 886, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.6/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)

jtpio commented 6 years ago

Are the credentials (TRELLO_API_KEY and TRELLO_TOKEN) provided when using the docker run command?

docker run -t -e TRELLO_API_KEY=YOUR_KEY -e TRELLO_TOKEN=YOUR_TOKEN ...
rcodecom commented 6 years ago

Yes they are. I also used the Trello Sandbox to verify whether the credentials are right and the sandbox manages to fetch all the board content correctly.

rcodecom commented 6 years ago

I also tried to create a new Trello account and tested it out, same results. I am trying from an iMac and a Macbook as well as a Synology NAS, same results on each.

I also tried accessing the URL you mentioned above in Postman as well as the browser and it works fine every time, returning all the boards. It's just the script that's failing. Anything else I can try?

adrienjoly commented 4 years ago

As mentioned in https://community.atlassian.com/t5/Trello-questions/Re-Re-Trello-API-Invalid-Key/qaq-p/1282962/comment-id/21077#M21077, I was getting the same error when trying to run trello-full-backup with Docker, because my Trello Token was wrong (32-chars-long instead of 64), because the Token generation URL I had provided in .env.example was missing the response_type=token parameter.

mjf-ans commented 2 years ago

I've had this happen intermittently, with a large board where sometimes the API fails with status 504 Gateway Timeout.

I've created https://github.com/jtpio/trello-full-backup/pull/37 which makes it a bit clearer what's happening by raising an HTTPError instead of JSONDecodeError. (It was trying to JSON-decode the HTML error body.)

adrienjoly commented 1 year ago

For reference, I got that error again today.

I fixed it by replacing the following parameter: --env-file ./.env (file in which TRELLO_API_KEY and TRELLO_TOKEN are defined) by -e TRELLO_API_KEY="xxx" -e TRELLO_TOKEN="xxx", in the docker command.