Removing multiple projects from a task

I am able to remove a project from a task via API, but am having trouble removing multiple projects from a task via API. I am trying to reduce the number of steps and calls to make.

Is this even possible?

@Emily_Roman, Can you perhaps move this to #developersapi ?

And @Phil_Seeman, I assume you’ll answer this even before that happens!!

Thanks,

Larry

2 Likes

Actually I can move it and answer it! :slight_smile:

Hi @Bobby_Lim1 - the specifics would depend partly on how you’re accessing the API - via an official client library or your own code - but in general, the projects that a task is attached to are an array property on the task, so if you remove multiple elements from that array and then save the task, that should remove it from those multiple projects in one call.

Does that make sense?

3 Likes

You can’t remove projects from a task using that method.
I don’t remember if it does nothing, or generates an error…

You can add them all, when you create a new task, using that method, by prividing ids of projects or sections. (sections is better, the project is auto-added)

But, after the task is created, you need to add / remove projects one by one.

https://developers.asana.com/docs/remove-a-project-from-a-task

So, to remove 3 projects on task 12345, you need to POST 3 times to:

/api/1.1/tasks/12345/removeProject.,
with these payload:
{“data”:{“project”:“11111”}}
{“data”:{“project”:“22222”}}
{“data”:{“project”:“33333”}}

Ah yes, thanks for the correction, @Frederic_Malenfant - it would have been good if I had looked at my code base before answering!

I do the same thing, call the removeProject endpoint, and only one at a time permitted.

2 Likes

Thanks all!
When I tried to remove multiple projects from a task in an array, it would only remove the last listed project.