Create project from a template in python

Is there a way to create a project using a template in Python? Or a way to duplicate a project from python?

My goal is to set up a new environment in Asana for the next year based on a template I made. I first thought was to copy the JSON structure of the project I created and loop it 200 times while changing the project name from a. But when I used client.projects.find_by_id, it did not give me tasks or sections.

Can you advise on possible solutions to this?

Hi @Revanth_Chintala and welcome to the forum!

You don’t need to do it manually or loop or anything - there is an API function to duplicate a project:

https://developers.asana.com/docs/#duplicate-a-project

This endpoint is in the Python client library.

1 Like

Thanks a lot! Here is my rough solution, if anyone in the future has a similar issue:

headers = {
‘Content-Type’: ‘application/json’,
‘Accept’: ‘application/json’,
‘Authorization’: ‘Bearer access token’,
}

data = {
“data”: {
“name”: "New Project ",
“team”: testing_team_id,

}
}

response = requests.post(‘https://app.asana.com/api/1.0/projects/proj_id/duplicate’, json = data, headers=headers)
for x in response:
print(x)