Reputation: 36
I'm trying to use Asana events API to track changes in one of our projects, more specific task movement between sections. Our workflow is as follows:
My idea was to use https://asana.com/developers/api-reference/events to implement a pull-based mechanism to obtain recent changes in tasks.
My problems are:
Ideas or suggestions are welcome. Thanks
Upvotes: 0
Views: 587
Reputation: 848
In short:
memberships
field on a task and not the other way.This should help you achieve what you are looking for, I think.
Let's say you have a project Ninja Pipeline
with 2 sections Novice
& Expert
. Keep in mind, sections are really just tasks whose name ends with a :
character with a few extra features in that tasks can belong to them.
Events "bubble up" from children to their parents; therefore, when you the Wombat
task in this project form the Novice
section to Expert
you get 3 events. Starting from the top level going down, they are:
Ninja Pipeline
project changed.Wombat
task changed.Wombat
task.For your use case, the most interesting event is the second one about the task changing. The data you really want to know is now that the task changed what is the value of the memberships
field on the task. If it is now a member of the section you are interested in, take action, otherwise ignore.
By default, many resources in the API are represented in compact form which usually only includes the id
& name
. Use the input/output options in order to expand objects or select specific fields you need.
In this case your best bet is to include the query parameter opt_expand=resource
when polling events on the project. This should expand all of the resource
objects in the payload. For events of type: "task"
then if resource.memberships[0].section.id=<id_of_the_section>
is true, take action, otherwise ignore.
Upvotes: 0