API Events

Hello guys!!! I am trying to get all the events of projects and tasks with the api (Events), the question is that it returns nothing. How should it be ‘param’ to get result?
opt_fields= [‘action’]
#resource = id project
resource = ‘1234’

for event in client.events.get_iterator({‘resource’:resource},opt_fields=opt_fields):


response geta <Response [412]>
response https://app.asana.com/api/1.0/events?resource=1163738599691137
response geta <Response [200]>
response {‘data’: , ‘sync’: ‘19c80683d78543e54549f5ede0515db5:1’, ‘has_more’: False}
response geta <Response [200]>
response {‘data’: , ‘sync’: ‘19c80683d78543e54549f5ede0515db5:2’, ‘has_more’: False}

Thank you for your time

Hi, what I see is the api returns exactly what is supposed to, a “sync token”.

You should use that token to re-query the api later, and you will get in return events that occurs between both calls, that’s how it works.

It’s a little bit like webhooks, it’s like if you query for webhooks, instead of receiving them automatically.

But, is it really what you want?
Or you need to get “task history” for a projet?, to see what happen in it?
These are not “events”, but “actions” for each tasks.
And, there’s no history (actions) for projects, just for tasks.

hi frederic, what I’m looking for is to see the changes on a resource("{action : created}","{action : modified}","{action : deleted}") use the Events object and I don’t get results, It is in an infinite cycle.

response {‘data’: , ‘sync’: ‘19c80683d78543e54549f5ede0515db5:2’, ‘has_more’: False}
response {‘data’: , ‘sync’: ‘19c80683d78543e54549f5ede0515db5:3’, ‘has_more’: False}

only changes in the last digit after the “:”, increasing by one.

I put a print () inside Object Clients of the “Asana API”, to see if it is searching.

thanks for your help…

I just tried it, and it works as expected.

  1. First query, to “start” the event process.
    GET /events/?resource=xxxxx
    (the resource is a task).
    I got a token in response, yyyyy:0.
  2. A little bit later:
    GET /events/?resource=xxxxx&sync=yyyyy:0
    Response is empty, because there was no changes in the resource.
    the response token become yyyyy:1.
    From now, I think that you can query using token:0, to get all changes since you got the initial token, or token:1, to get changes since that last query.
  3. Then, I edit my task, I just changed the name.
  4. And, I query events another time:
    GET /events/?resource=xxxxx&sync=yyyyy:1

Now, I have some data, 2 records.
First, type:task, action:changed, and the resource with the changed fields (name).
And, a type:story action:added, + the details.

And, a new token usable to query the next changes. But this token is now complete new, ending with :0.
I think that the increment occurs each time you query for events, and there’s no changes.

I can also query again my previous token, (0 or 1), and I get the previous results.

Events api is used to get changes for a period of time, between 2 /events query for that resource.

  1. Subscribe to an event resource, get the token, keep it.
  2. wait for changes in the resource,
  3. query for these changes using the sync token you got in 1