Asana Events API - Events not returned despite new sync token

Hi there,

I keep getting the following error despite looping through and using the sync token that is generated from my API call for the same resource.

{'errors': [{'message': 'Sync token invalid or too old. If you are attempting to keep resources in sync, you must fetch the full dataset for this query now and use the new sync token for the next sync.'}], 'sync': '5cbae2ac7386ccbe5eeae3e9a3f86339:0'}

I’ve tried using both Postman and a python script but return this same error.

My aim is to be able to track and see if the due_date has changed on a task and when it has changed, hence why I wanted to use the events endpoint to loop through all tasks in a project.

This is my script which currently doesn’t return any event data - any help would be much appreciated!

     headers = {
        'Authorization': 'Bearer xyz',
        'Cookie': 'TooBusyRedirectCount=0'
    }

    tasks = ['x', 'y', 'z']
    try:
        for task in tasks:
            while True:
                event_endpoint = f"https://app.asana.com/api/1.0/events?resource={task}&sync_token={sync}"
                response = requests.get(event_endpoint, headers=headers).json()

                # retrieved sync token from here
                sync = response['sync']
    except:
        return None

Many thanks!

Please read this before posting

  • If you received an error from the API that you’re looking for help with, please include the error in your post and be descriptive of the requests you made that received the errors. To be clear, we need the error in the JSON response from the API, not the error your code raised.
  • Do not share any API credentials. Please check that the code you’re pasting into the post does not contain any real OAuth tokens or personal access tokens. If you have exposed credentials, you should revoke them immediately.