trello-full-backup icon indicating copy to clipboard operation
trello-full-backup copied to clipboard

Exception JSONDecodeError

Open vizcay opened this issue 8 years ago • 8 comments

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)
  • I have double checked that the environment variables are set.
  • I have installed requests via "pip3 install requests"
  • I'm running python 3.5.2 on Mac OS X El Capitan installed via homebrew (python3)

Any idea? thanks

vizcay avatar Aug 12 '16 13:08 vizcay

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!

jtpio avatar Aug 22 '16 22:08 jtpio

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)

rcodecom avatar Mar 13 '18 21:03 rcodecom

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 ...

jtpio avatar Mar 14 '18 14:03 jtpio

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 avatar Mar 14 '18 20:03 rcodecom

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?

rcodecom avatar Mar 18 '18 08:03 rcodecom

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.

adrienjoly avatar Jan 26 '20 16:01 adrienjoly

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.)

mjf-ans avatar Aug 10 '22 14:08 mjf-ans

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.

adrienjoly avatar Jun 19 '23 09:06 adrienjoly