Upload excel files in trello card via python as attachments

Hello!

I want to upload an excel file (.xlsx) into a card as an attachment. However, if I open the card, I can only download an attachment with the type application/octet-stream. How can I upload the file so that a card user (not necessarily me) can see the contents of the excel file?

I wrote the following code:

import requests

key = “cf96243c3494a8473e5caccd2d0f906c”
token = “{{REVOKED}}”

query = {
‘key’: key,
‘token’: token,
‘file’: ‘10228-PA.xlsx’,
‘name’: ‘10228-PA.xlsx’

response = requests.request(
“POST”,
url = “”.join((“https://api.trello.com/1/cards/”, ‘NU6mdURG’, “/attachments”)),
params=query
)
I think it might have something to with mimeType. Can somebody help me how to change the code?

:wave: Hi @RobertKomorowsky

Quick note: Please do not share API tokens. They should be kept secret at all times. I’ve gone ahead and expired the one you posted so you’ll need to generate a new one.

Not going to lie, attachments are tricky to work with over REST. I put together this project to help show different ways of interacting with the attachments endpoints: Glitch :・゚✧

There is also this question and solution from awhile back that might point you in the right direction: Attaching PDF attachments fail in the API POST call - #2 by bentley