Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to correctly set filename (not name) of card attachments via the Trello REST API

Celine Hernia
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!
October 19, 2022

I have a function/method that creates a new attachment, particularly a text file, to a card. It successfully attaches the file to the card but when downloaded locally, the filename is always set to "Upload", not the actual filename "*.txt". Here's my function:


def create_attachment_on_card(self, card_id, filename):
creates a file attachment on a card
url = f"{card_id}/attachments"

with open(f'dataset/{filename}.txt', 'rb') as file:
content =

query = {
'key': self.key,
'token': self.token,
'name': f'{filename}.txt',
'file': content,
'mimeType': 'text/plain'

response = requests.request(
return response.status_code


I would greatly appreciate any input on this. Thank you!

1 answer

0 votes
Adam Cao
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
October 19, 2022

I would recommend setting the filename field in your multipart/form-data payload that you send to Trello when you upload the attachment (i.e. your other function).


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events