Unable to create webhook for added/deleted task

When trying to create a webhook to detect added/deleted tasks, using the following criteria:

{
    "data": {
        "filters": [            
            {
                "action": "deleted",
                "resource_type": "task"
            }
        ],
        "resource": "<project_gid>",
        "target": "target_url"
    }
}

I get the following error → "message": "filters: [1]: fields: Not an array"

I then tried to add an empty (or populated) fields array

"fields": [
    "name"
]

Which results in the next error → "message": "Filtering on fieldsis only possible onactionof typechanged.",

I have a webhook that detects changes to tasks correctly, so what am I doing wrong in this instance?

Hmm, that looks right to me.

Just curious, what happens if you add a “changed” filter to what you have?

Thanks for getting back @Phil_Seeman. The changed filter that I have for a current webhook works fine

"filters": [
            {
                "action": "changed",
                "fields": [
                    "assignee",
                    "due_on",
                    "custom_fields",
                    "name"
                ],
                "resource_type": "task"
            }
        ]

I am unsure how to to alter it to capture task deletions.

Also tried the following:

 "filters": [
            {
                "action": "changed",
                "resource_type": "task"
            }
        ]

which results in the same error as before → "message":"filters: [0]: fields: Not an array"

@Dennis_Joseph What happens if you do this?

"filters": [
            {
                "action": "changed",
                "fields": [
                    "assignee",
                    "due_on",
                    "custom_fields",
                    "name"
                ],
                "resource_type": "task"
            },
            {
                "action": "deleted",
                "resource_type": "task"
            }
        ]

@Phil_Seeman, gave that a whirl and I got the following message:
{"message":"filters: [1]: fields: Not an array"


Attached image - if that helps

Hmmmm… :thinking:

@David_Neal can you perhaps help here?

Hi @David_Neal, any chance you could help on this please?

Hi @Dennis_Joseph,

I’ve tested locally and found that creating a webhook (POST /webhook) using a project GID with the following syntax does work.

{
	"data": {
		"resource": "{project_gid}",
		"target": "{webhook-server-url}",
		"filters": [
			{
				"resource_type": "task",
				"action": "deleted"
			}
		]
	}
}

Is the resource you are establishing the webhook on a project GID? Are you able to share more of the code you are using to create the webhook? Feel free to message me privately, if needed.

1 Like

Thanks for the help @David_Neal. I think I found the issue based on the JSON body you used. Since I was using the same contract DTO object as the one that was used to change tasks, it was failing with the error since it expected Filters to exist and be populated.

Creating a new contract object without the Filters field helped.

Thanks @Phil_Seeman for looking into the issue and redirecting to help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.