Copying a Project


#1

Is there a way to use the API to copy an existing project? I haven’t been able to find anything directly and I thought about manually creating a project with the corresponding sections and tasks but using the Batch API, they are all unordered and it is a lot of calls to be making. Has anyone found a work around for this or does Asana have any plans to add a copying endpoint to the API?


#2

List View project or Board View project?

You will have to do it manually. But it’s not unordered; when you do this

GET    /projects/projectId-id/tasks

the API returns the tasks in the same order they are shown in the UI for that project. If it’s a List View project, the sections will just be tasks within that returned list. If it’s a Board View project, you will have to do a bit of extra work to get the sections.


#3

Right but then how do I use that to create a new project? Do I have to loop over that list and send as many requests as there are tasks?


#4

Yeah, you would have to do just that.

You’re also going to have to decide how you want to handle subtasks - are you going to copy those as well? If so, for each task you get in the project, you’ll have to recursively call

GET    /tasks/task-id/subtasks

and add those as well.


#5

@TJ_Carney – unfortunately, there is no ‘copy_project’ endpoint. You could use the batch API to reduce the number of calls, however, the general logic would be what Phil outlined.


#6

A bit of warning about the tasks order, my testing revealed a few times that the order in the API is actually not the order of display but rather the order of creation (or something else I don’t understand).

Sometimes duplicating the project first helps to keep the right order (especially for boards, tried with list this morning and did not work…). @Jeff_Schneider do you confirm this?


#7

That’s not good news, since I’m relying on the correct order for my application. If you can find a reproducible case, can you file a bug report with the Asana API team? @Jeff_Schneider or @Joe_Trollo, do you have any info on an issue with the item ordering?


#8

I don’t remember where I raised the issue (the Slack channel with developers I think) and the answer was something like “ok” :stuck_out_tongue:
Test case is easy I think. Add tasks, change their order, and query the list. I never did it, only saw with my own eyes…


#9

Thanks for the help, everyone! I really hope an easy copy_project endpoint is available in the future! It would make our automation a lot more smooth!


#10

Tasks in the API should be returned in the order they appear in the project without extra sorting, i.e., they will match the project when the view settings are

If you sort the project by some other attribute in this dialog, that will not be reflected in the API.


#11

@Bastien_Siebman Bastien, is it possible this is what was going on when you saw an order discrepancy?


#12

As a matter of fact my client just told me she indeed sort the project and I did not see it! So the order in list is kept I think. My bug still remains in boards.


#13

Also, care when adding sections and sub-tasks, they need to be added in reverse order to maintain the initial order (sorry for tautology).