Asana WebHook error 'You should specify one of resource' when executing webhook

I successfully deployed my asana app and the endpoints to heroku which are now all working.

Now i’m trying to execute the webhook. I’m currently getting the error with the message

message: 'You should specify one of resource',

2021-09-22T17:20:27.693066+00:00 app[web.1]: help: 'For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors'
I have two web-hooks
  1. My first webhook would execute the target script when a new task is added to a section :
    note: the the resource id here im using is the section id.
  var webhookEvent = {
        "data": {
        "filters": [
            {
              "action": "added",
               "resource_type": "task"
            }
          ],
          "resource": "XXXXXXXXX", // This is the id of the section  
          "target": "https://XXXXXXX/create_task" // this is where web-hooks script is
      }  
    }
  1. The second webhook is to execute a different script when a specific task in a section is marked as completed (TICK)
    note: the resource id im trying to use here the task id.
var webhookEvent = {
“data”: {
“filters”: [
{
“action”: “changed”,
“fields”: [
“completed” // when your clicks completed it will generate the task
],
“resource_type”: “task”
}
],
“resource”: “XXXXXXXXXX”, // This is the id of the generate score field task
“target”: “https://xxxxxx/score” // this is where your web-hooks
}
}

Could you help me to correct my syntax here for the filter i’m using for both 1 and 2.
Or is there anything else i’m doing wrong?

I would greatly appreciate your help here.

Thanks

Hi @Damilare_Olowoniyi,

You can’t set a webhook on a section. Instead, set the webhook on the project where the section resides; then when you get a webhook event, you’ll need to check the webhook’s task in your code to see if it’s in the desired section and if so, take the desired action.

Hi Phil thanks for responding. i’m trying to recreate this still seeing error.

What would be the syntax for the filters i need here? for both 1 and 2?

Thanks.

Does anyone know the correct syntax in NodeJs for the webhook Filter I need to use to:

  1. Get any added tasks added to a section
    It would execute my target url

  2. When a specific task in a section is marked as completed
    It would execute the target url

I would appreciate anyone help on this.

@Damilare_Olowoniyi,

Your filter syntax looks ok to me.

If you haven’t yet, I highly recommend you try it without filters first - i.e. keep the webhook setup as simple as possible until you know it’s being created without errors; only then try to create it with the filter.

1 Like