Create a Project using a custom template in python

I would like to create a project in asana through an API using a custom template.
The custom template already exists in Asana so I would like to know to specify that when you create the project.
I have tried the following, the project has been created but not using the template
client = asana.Client.access_token(personal_access_token)
client.headers={‘asana-enable’: ‘string_ids’}

project = {‘name’:‘test’,‘workspace’:‘856…’,‘team’:‘1163…’,‘custom-template’:‘113776…’}

Any idea ?

What you want is the duplicate_project function.

See Asana

I don’t think so, basically I have my own custom template in asana, manually, when I create a project I chose which template I use, when I hit to create a project and select the template I can see this , now I would like from python create a projet using that template

The web app isn’t built on the API; the API and web app are completely unrelated. There’s no support in the API for the endpoint and parameter you’ve mentioned.

Alright, and to duplicate a project do you have the exact python expression ?
something like
project = {‘name’:‘test’,‘workspace’:‘856…’,‘team’:‘1163…’}

Afraid I’m not up on the Python library specifically. Best thing is to check the library source on Github. This is from that repo and should be helpful (along with the documentation I linked to above):

# Creates and returns a job that will asynchronously handle the duplication.
  # name - [String] The name of the new project.
  # team - [Gid] Sets the team of the new project. If team is not defined, the new project
  # will be in the same team as the the original project.
  # include - [Array] The elements that will be duplicated to the new project.
  # Tasks are always included.
  # schedule_dates - [String] A dictionary of options to auto-shift dates.
  # `task_dates` must be included to use this option.
  # Requires either `start_on` or `due_on`, but not both.
  # `start_on` will set the first start date of the new
  # project to the given date, while `due_on` will set the last due date
  # to the given date. Both will offset the remaining dates by the same amount
  # of the original project.
  # options - [Hash] the request I/O options.
  # data - [Hash] the attributes to post.
  def duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data)
    with_params = data.merge(name: name, team: team, include: include, schedule_dates: schedule_dates).reject { |_,v| v.nil? || Array(v).empty? }"/projects/#{gid}/duplicate", body: with_params, options: options)).first, client: client)

thanks @Phil_Seeman it works well, this is how I resolved it.
req = {
‘project’ : ‘11639759935799’,
‘data’: {
‘name’ : ‘test’,
‘team’ : ‘11635395161994’

1 Like