Webhooks not working

We have registered wehooks for a url and we are not receiving any message from asana when user completes the task.

Please help us to fix it.

Just to elaborate - We’ve registered to the webhook using the following request:
curl -H "Authorization: Bearer 0/XXXXXX" https://app.asana.com/api/1.0/webhooks/[project_id]

And received a success message:
{"data":{"gid":"939792628xxxxxx","id":93979262xxxx,"resource_type":"webhook","target":"https://leaderboard.airfleet.co/asana/receive-webhook","active":true,"created_at":"2018-12-10T06:43:20.130Z","last_failure_at":null,"last_failure_content":"","last_success_at":null,"resource":{"gid":"XXXXXX","id":XXXXXX,"resource_type":"task","name":"test Shashi","resource_subtype":"default_task"}}}

Just to elaborate - We’ve registered to the webhook using the following request:
curl -H "Authorization: Bearer 0/XXXXXX" https://app.asana.com/api/1.0/webhooks/[project_id]

And received a success message:
{"data":{"gid":"939792628xxxxxx","id":93979262xxxx,"resource_type":"webhook","target":"https://leaderboard.airfleet.co/asana/receive-webhook","active":true,"created_at":"2018-12-10T06:43:20.130Z","last_failure_at":null,"last_failure_content":"","last_success_at":null,"resource":{"gid":"XXXXXX","id":XXXXXX,"resource_type":"task","name":"test Shashi","resource_subtype":"default_task"}}}

But when using:

curl -H "Authorization: Bearer XXXXXX" https://app.asana.com/api/1.0/webhooks?workspace=[workspace_id]

We get an empty response:
{"data":[]}

This is a known issue - see this topic:

Your webhooks should still be operational even though that query returns an empty array.

Thanks @Phil_Seeman for the reply. But we are not receiving any webhook messages for any events from asana.

1 Like

I’m having this exact issue, they are not being created and making changes to the resource doesn’t POST anything to my server - Webhooks Not Creating after Showing Successful Response - #2

Hello,

I am able to create a Webhook and send a 200 status + X-Hook-Secret from the POST request. If I output webhooks from the creation, it will show me a Webhook ID, etc.

When I try to find the Webhook, it doesn’t exist. Do I need to add something else to confirm the creation of the Webhook? Please see code below, thank you.

var express = require('express');
var router = express.Router();
const asana = require('asana');
const client = asana.Client.create().useAccessToken('0/976b32*****************');

projectId = '938098182704541';

router.get('/', function (req, res, next) {
	client.webhooks.create('938098182704541', 'https://mydomain.com/asana-webhook-test/' + projectId)
		.then(function(webhooks) {
			console.log(webhooks);
			res.sendStatus(200);
		})
		.catch(function(err) {
			console.log(err.value);
			res.sendStatus(400);
		});
});

router.post('/' + projectId, function (req, res, next) {
	var xHookSecret = req.headers['x-hook-secret'];
	
	if (xHookSecret) {
		res.setHeader('X-Hook-Secret', xHookSecret);
		res.sendStatus(200);
	}
});

module.exports = router;

I get a response from ‘console.log(webhooks)’, but after finishing the running of the script, running client.webhooks.getAll(workspaceID) brings back 0 results. I checked in browser too and 0 results. Thank you.

I’m also not receiving events for the resources that I’m being told are being created. What’s up here?

Hi all, I have an update to share on this issue. After a long time of being unable to reproduce this in our testing and production environments, we believe we have found the source of this bug.

Because there have been other threads about webhooks issues, this particular issue we have found (just to be explicit) is as follows: a app creates a webhook, successfully completes the handshake by responding with the secret header, and then the webhook immediately vanishes (it does not appear in the list of webhooks for the workspace, and cannot be retrieved by ID). The webhook also does not fire for any events, having been deleted.

We believe the issue to be related to how webhooks decide to delete themselves. A webhook will delete itself under three circumstances:

  • You’ve made a request to DELETE /webhooks/<id>
  • You’ve responded to a webhook with a 410 Gone status code
  • The webhook was unable to deliver any payloads for a full week

The last of these is the only method by which a webhook will delete itself without being explicitly told to by the app. Webhooks keep track of the last time that delivery succeeded, and this is updated with each success. Webhooks also have a “heartbeat” that will deliver an empty payload every eight hours, so even if there is no activity on the resource we are still continuously updating the last success time.

There is one edge case where this breaks down: the very first heartbeat. As soon as the handshake is complete, we begin the heartbeat and send an empty payload. Because this is the first ever delivery attempt and there are no previous recorded successes, the “last success time” still has a default value of 0 in our data model. If the client fails to receive this first payload, the time difference between “now” and 0 is, at time of writing, approximately 49 years. The webhook believes it hasn’t succeeded in more than a week, and so deletes itself.

This took us a long time to diagnose because detection required our own test webhook receivers to succeed with the handshake and then immediately fail, and it seems we’re quite good at listening to our own webhooks. We have just patched the issue, and now the initial handshake will also count as a “success” for the purposes of self-deletion. Thus, if your app fails to receive the very first heartbeat, it will continue to retry and deliver other events for a full week after creation…

Thank you all for your patience while we hunted down the bug! Please let us know if you continue to encounter this specific issue after the patch has been deployed, which should happen by Wednesday afternoon.

2 Likes

Thanks for the detailed explanation, Joe! Gotta love those edge cases.

I am trying to setup a webhook for a project resource and for the filter type changed. I have specified fields as you can see in the screenshot but also tried without fields and in both cases i get an empty 200OK response. I need to know what’s causing this and how to fix it. TIA

Hi @anon65587993,

Your endpoint URL string should specify just /webhooks not /webhooks/workspace. See the API docs here.

Hi @Phil_Seeman thanks for the response. I did try that initially and when i use /webhooks i get an error message “You should specify one of workspace”. See the attached screenshot for reference.

My recollection is that error means that the gid you’re specifying for resource is not a valid workspace gid. You definitely don’t want to be adding /workspace to the URL.

@Phil_Seeman Thank you again for responding. I understand that i should be using /webhooks and i have changed my URL as well. What i don’t get it is how come the gid not being accepted. I have used a task ID and i got the same “You should specify one of workspace” error. I also used a project ID and got the same error. I don’t understand why these IDs are not being accepted.

The resource_type of the filter should be project, not task.

The gid you specify for resource is the workspace gid of the workspace you want the webhook active in.

Are you specifying a valid workspace gid for resource?