I have a case: I want to create a webhook to notify the system when a certain user is added or deleted to/from a project. In this webhook I need to get a project’s ID.
Is there a possibility to subscribe on users’s projects list and to get notifications when the list is updated?
Thanks a lot!
Hi @Maksim_Ivasenko and welcome to the forum!
Yes, you can do this.
What you can do is set up a webhook on the user’s workspace with a filter of “project_changed”. That way, whenever any project is changed, you get an event with that project ID.
(You might be able to further refine that filter by specifying the
fields filter parameter with the field
members - I haven’t tried that level of filtering on a project but theoretically it should work.)
However, the webhook event won’t tell you exactly what data has changed, so in order to know if a member (user) was added or removed, you’ll have to maintain a list or database on your end of each project and the members in it. Then when you get a notification that a project has changed, you can retrieve that project from Asana and compare its current
members property with your own list to see if there are any differences from the addition/removal of users.
You can read about webhooks and filtering here: Asana
Let me know if you have any questions about any of the above.
Thanks a lot for your answer.
The main goal is to receive updates only for one certain user with specific
gid. And these updates will tell our service if this user was added to new projects or not.
It is important to subscribe exactly on the user, because in my company about 1500 employees use Asana, and a lot of projects are created daily, so our service will receive redundant number of requests which can be irrelevant if the needed user is not a member of the project.
Is it possible?
Thanks a lot!
You can’t set a filter for one user, but what I would do in that case is get a Personal Access Token for that user so that you’re at least only retrieving their data. You’ll still have to check each webhook event you receive to see if that user was added/removed from a project, but at least you won’t get events for projects that user doesn’t have access to.
@Phil_Seeman thanks a lot! I’ll try to do it.