I have a webhook setup that is captured in zapier to start an automation on a project board
<Asana /webhooks/1202824082522084>
List of 1
$ data:List of 10
..$ gid : chr "1202824082522084"
..$ active : logi TRUE
..$ created_at : chr "2022-08-18T19:53:01.473Z"
..$ last_failure_at : NULL
..$ last_failure_content: chr ""
..$ last_success_at : chr "2022-08-21T07:46:09.893Z"
..$ resource :List of 3
.. ..$ gid : chr "1202785046413617"
.. ..$ name : chr "The Board Name"
.. ..$ resource_type: chr "project"
..$ resource_type : chr "webhook"
..$ target : chr "https://hooks.zapier.com/hooks/catch/13165208/xxxxx/"
..$ filters :'data.frame': 1 obs. of 4 variables:
.. ..$ resource_type : chr "story"
.. ..$ resource_subtype: chr "section_changed"
.. ..$ action : chr "added"
.. ..$ fields : logi NA
I have noticed that it is triggering zapier even when nothing changes on the resource project
I am not sure what error I could even put in since zapier is ingesting the webhook. All I can see is that the output is empty
I was having trouble anyways with phantom task_id’s sent by the api through the webhook see this issue
so i put in a check step to see that the task_id exists on the project board
import requests
import re
ACCESS_TOKEN = input_data['ACCESS_TOKEN']
API_URL = "https://app.asana.com/api/1.0"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
url = f"{API_URL}/projects/{input_data['project_id']}/tasks"
r = requests.get(url, headers=headers)
tasks = r.json()["data"]
i = 0
for x in tasks:
i = i + int(x['gid']==input_data['task_id'])
found = bool(i)
output = {'found': found}
This code is breaking because input_data['task_id']
is empty from the webhook initial step and returns
Traceback (most recent call last):
File "<string>", line 22, in the_function
KeyError: 'task_id'
My main concern is that nothing is actually happening on the board and the webhook is being triggered. I can always create logic around it to stop the error, but I would want to understand if I set something up wrong first.