Creating a Card from Template card - Getting Error 400

I’m trying to create a card from a template card (which have checklist). I’m getting an response 400. When I remove idCardSource parameter in the params, I’m able to create a new card (Without referring to template card). Can you help me how to use template to create a new card from it. Template ID is correct, I could retrieved the template name with it.

This is what my code is

import requests

api_key = ""
api_token = "
:
template_card_id = ‘WyxxZAsh’
new_list_id = “643facf55z954a79e5ff3dca”
new_card_name = “URL CARD”

url = f"https://api.trello.com/1/cards"

query_params = {
“key”: api_key,
“token”: api_token,
“idList”: new_list_id,
“name”: new_card_name,
“idCardSource”: template_card_id,
}
print (query_params)
response = requests.post(url, params=query_params)
print (response)
new_card_data = response.json()
print (new_card_data)

What was the method you used to ‘retrieve’ the template card’s name based on that ID?

Given that card IDs are 24 characters long, always contain numbers and don’t use upper case letters, then ‘WyxxZAsh’ is highly unlikely to be a valid ID.

I think you’re confusing the template card’s id with its shortLink.

Yes, you are correct. I was using wrong ID. Thank you for pointing that out. :+1:

1 Like

No problem. It’s good etiquette on the forum to mark an answer correct if it is, as it improves the rating of the answerer.