I created a webhook on a project resource, with a filter to get ‘task’ resource_type and ‘added’ action.
My intention is to get notified when tasks are added to this project. I am also checking for the parent to have resource_type ‘project’. With these it is working to filter out creation of sub-tasks. There is an unexpected case: when I assign a sub-task to somebody I receive an ‘added’ event on my webhook, with the ID of the sub-task and parent resource_type ‘project’.
Can somebody explain me why is this and isn’t this a bug in the webhook/events API?
Subtasks are not part of the project, so that would be surprising the webhook fires at all, unless Asana is slowly making the subtasks part of the project. Maybe @Phil_Seeman can help, he is the webhook wizard.
Remember that each Asana user has a User Task List (i.e. their “My Tasks” list) which, while not exactly a normal project, is considered a “project” in the Asana data model.
If you check the gid of the project listed in the added event, you’ll see it’s not the gid of the project where you made the assignment; rather, it’s the gid of the assignee’s User Task List. When you assign a task to someone, that task gets added to their User Task List, and that’s the added event you’re seeing.
So (you’ve probably already figured this out by now) you can look at the project gid in the webhook and if it doesn’t match your project gid, you can ignore that added event.
I’m sure this is the same thing - it’s the task being added to the assignee’s User Task List.
I don’t think I would characterize it as they’re slowly making subtasks part of the project, as that implies a change in the data model itself which I don’t think is happening, but I did make this same discovery just a couple of weeks ago: that I’m getting webhooks on subtasks in projects where I have a webhook set. I’m 95% sure this was not happening when I started using webhooks a few years ago and was added sometime since then, but I have no idea how long it’s been the case.
@Joe_Trollo@Ross_Grambo, what say you - is this a pretty recent occurrence where we get webhooks on subtasks that aren’t attached to their parent task’s project, or has it been happening all long and we just missed it?
Thank you @Phil_Seeman, you are indeed correct and I can verify that the project ID is the assignee’s User Task List.
I guess it was a bit unclear for me, that if I created the webhook on the specific project, I would still get an event when that project’s task is added to a different project. But hey, once the behavior is understood, I can work with that.