Error 403 when using API from terminal

Mikhail Ponomarev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2024

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(
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: {}\nTitle: {}')
for board_list in board.list_lists():
print(f'Information about list: \nID: {}\nTitle: {}')

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\", line 82, in <module>
File "D:\Python Projects\ubego_spiff_task_form\python_utils\trello_manager\", 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\", 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\", 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" "">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
<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">
Generated by cloudfront (CloudFront)
Request ID: 
</BODY></HTML> at (HTTP status: 403)


I would be very grateful for any advice and help. Have a nice day!

1 answer

0 votes
Andrea Crawford
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 20, 2024

@Mikhail Ponomarev  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

Let me know if you have further questions. 

Mikhail Ponomarev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2024

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?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events