You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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"https://api.trello.com/1/cards/{card_id}/attachments"
with open(f'dataset/{filename}.txt', 'rb') as file:
content = file.read()
query = {
'key': self.key,
'token': self.token,
'name': f'{filename}.txt',
'file': content,
'mimeType': 'text/plain'
}
response = requests.request(
"POST",
url,
headers=self.std_headers,
params=query
)
return response.status_code
I would greatly appreciate any input on this. Thank you!
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).
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.