2

I am trying to add an attachment to a pre-created Trello card

I know how to create the card, but so far I was not able to find how to add an attachment without providing the ID (because the card is not yet created)

in case of need : https://developers.trello.com/advanced-reference/card

I am using this to create the card :

https://api.trello.com/1/cards?key=<myKey>&token=<myToken>&name=My+new+card+name&desc=My+new+card+description&idList=<myIdList>
Scylla
  • 57
  • 5

2 Answers2

3

Ok I found the answer!

Create the card -> get the ID of the card in the process -> add attachments !

Scylla
  • 57
  • 5
1

I've used Python 3.5 and it worked this way:

#python 3.5.2

import requests

params = (
    ('key', 'yourkey'),
    ('token', 'yourtoken'),
)

files = {
    'file': ('C:\\Users\\mcronje\\Pictures\\Picture.png', open('C:\\Users\\Pictures\\Picture.png', 'rb')),
}

response = requests.post('https://api.trello.com/1/cards/ {cardidnumber}/attachments', params=params, files=files)


print(response.text)
Martin Cronje
  • 175
  • 1
  • 6