Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception JSONDecodeError #1

Open
vizcay opened this issue Aug 12, 2016 · 8 comments
Open

Exception JSONDecodeError #1

vizcay opened this issue Aug 12, 2016 · 8 comments

Comments

@vizcay
Copy link

vizcay commented Aug 12, 2016

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

@jtpio
Copy link
Owner

jtpio commented Aug 22, 2016

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
Copy link

rcodecom commented Mar 13, 2018

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
Copy link
Owner

jtpio commented Mar 14, 2018

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
Copy link

rcodecom commented Mar 14, 2018

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
Copy link

rcodecom commented Mar 18, 2018

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
Copy link

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
Copy link

mjf-ans commented Aug 10, 2022

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

I've created #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 added a commit to adrienjoly/backup-scripts that referenced this issue Apr 10, 2023
@adrienjoly
Copy link

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 added a commit to adrienjoly/backup-scripts that referenced this issue Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants