I am trying to create a card using Trello API. Name, description, and due date working seamlessly. But when I try to attach documents directly from Google Drive with ‘urlSource’, it either adds the document twice or puts its picture as a cover photo. I am simply trying to add the URL of the said document to the card, that’s all.
My function looks like this:
def create_a_card(self,
name="Test",
desc="Test",
pos=0,
due=f"{(datetime.today()+timedelta(days=1, hours=11)).isoformat()}",
due_complete=0,
url_source="",
id_members=[],
id_labels=[],
file_source="",
id_card_source=""):
url = "https://api.trello.com/1/cards"
query = {
'key': self.key,
'token': self.token,
'idList': self.target_list.get('id'),
'name': name,
'desc': desc,
'pos': pos,
'due': due,
'dueComplete': due_complete,
'urlSource': url_source,
'idMembers': id_members,
'idLabels': id_labels,
'fileSource': file_source,
'idCardSource': id_card_source,
}
response = requests.request(
"POST",
url,
params=query
)
return response.json()
When I am calling this function I use something like this:
create_a_card(name="test5", desc="[test again](www.google.com)", url_source="https://docs.google.com/document/d/{Google_Drive_File_ID}/edit")
I will try to do this with creating an attachment on a card, but I wonder what am I doing wrong here?
Some things I tried to make it work:
- Removing unused parameters from the query - same outcome
- Removing the /edit part from the drive link - same outcome
- Trying to add some other link - works good, no cover, no duplicate
So, I appreciate any ideas on this topic. Thanks!
Edit: It worked with first creating a card, and then adding the attachment. But the problem still stands.