Hello, dear members of the community!
I am facing this problem, I am using py-trello library to interact with Trello API.
I have a class that works with Trello and outputs all the boards and all the lists in them, it works fine if you run it in PyCharm using the run button.
This is what my class looks like:
class TrelloManager:
board_id = os.getenv('TRELLO_BOARD')
todo_list_id = os.getenv('TRELLO_TODO_LIST')
done_list_id = os.getenv('TRELLO_DONE_LIST')
trello_api_key = os.getenv('TRELLO_API_KEY')
trello_api_secret = os.getenv('TRELLO_API_SECRET')
trello_token = os.getenv('TRELLO_TOKEN')
trello_token_secret = os.getenv('TRELLO_TOKEN_SECRET')
def __init__(self):
"""Used to initialise variables and raise exceptions if they are not present"""
if self.trello_api_key is None:
raise EnvironmentError('Variable TRELLO_API_KEY does not exist')
elif self.trello_api_secret is None:
raise EnvironmentError('Variable TRELLO_API_SECRET does not exist')
elif self.trello_token is None:
raise EnvironmentError('Variable TRELLO_TOKEN does not exist')
elif self.trello_token_secret is None:
raise EnvironmentError('Variable TRELLO_TOKEN_SECRET does not exist')
elif self.board_id is None:
raise EnvironmentError('Variable TRELLO_BOARD does not exist')
elif self.todo_list_id is None:
raise EnvironmentError('Variable TRELLO_TODO_LIST does not exist')
elif self.done_list_id is None:
raise EnvironmentError('Variable TRELLO_DONE_LIST does not exist')
self.client = TrelloClient(
api_key=self.trello_api_key,
api_secret=self.trello_api_secret,
token=self.trello_token,
token_secret=self.trello_token_secret
)
self.board = self.client.get_board(self.board_id)
self.todo_list = self.board.get_list(self.todo_list_id)
self.done_list = self.board.get_list(self.done_list_id)
def show_all_boards_and_lists(self):
"""Used to display information (ID, title) about all your boards and lists"""
all_boards = self.client.list_boards()
for board in all_boards:
print(f'Information about board: \nID: {board.id}\nTitle: {board.name}')
print('==========================================================================================')
for board_list in board.list_lists():
print(f'Information about list: \nID: {board_list.id}\nTitle: {board_list.name}')
print('==========================================================================================')
But when I run it through terminal, the following error occurs:
Traceback (most recent call last):
File "D:\Python Projects\ubego_spiff_task_form\python_utils\trello_manager\trello_manager.py", line 82, in <module>
TrelloManager().show_all_boards_and_lists()
^^^^^^^^^^^^^^^
File "D:\Python Projects\ubego_spiff_task_form\python_utils\trello_manager\trello_manager.py", line 66, in __init__
self.board = self.client.get_board(self.board_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python Projects\ubego_spiff_task_form\.venv\Lib\site-packages\trello\trelloclient.py", line 124, in get_board
obj = self.fetch_json('/boards/' + board_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python Projects\ubego_spiff_task_form\.venv\Lib\site-packages\trello\trelloclient.py", line 247, in fetch_json
raise ResourceUnavailable("%s at %s" % (response.text, url), response)
trello.exceptions.ResourceUnavailable: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID:
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML> at https://api.trello.com/1/boards/ (HTTP status: 403)
I would be very grateful for any advice and help. Have a nice day!
@[deleted] Hi there, I believe you're seeing this error due to a change so that the Trello api no longer accepts a body with a GET request. You can read more about it here https://developer.atlassian.com/changelog/#CHANGE-1459
Let me know if you have further questions.
Andrea, thank you so much for your response! But can you tell me why it doesn't work exactly from the terminal. That is, in fact, when receiving all the cards a GET request is sent and in this case it should not work under any circumstances. Or am I thinking wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.