Hi, I’m trying to use Asana’s webhooks, however, they keep disappearing after around 21.5 seconds. I’In Python I have the following (had the same issue using curl):
sandbox = requests.post("https://app.asana.com/api/1.0/webhooks", {'resource':resourceID, 'target':targetURL}, headers={'Authorization':"Bearer %s" %(token)})
I get a status of 200 and the expected response including an ID for the webhook. For 21ish seconds it appears in the list of webhooks from the following code:
abc = requests.get("https://app.asana.com/api/1.0/webhooks", {"workspace":workspaceID}, headers={'Authorization':"Bearer %s" %(token)})`
However after that time, the same request returns an empty list in data instead.
Well, I figured it out now. Apparently Asana will send an empty event to test the url, and if it fails, it will delete the webhook. I was assuming it would last for 24 hours at least, as per the documentation:
If we attempt to send a webhook payload and we receive an error status code, or the request times out, we will retry delivery with exponential backoff. In general, if your servers are not available for an hour, you can expect it to take no longer than approximately an hour after they come back before the paused delivery resumes. However, if we are unable to deliver a message for 24 hours the webhook will be deactivated.
That is not the case evidently. Also, future requests have X-Hook-Signature instead of X-Hook-Secret, causing the error in the first place for subsequent requests.
2 Likes
You saw
When a webhook is created, we will send a test POST to the target with an X-Hook-Secret header as described in the Resthooks Security documentation. The target must respond with a 200 OK and a matching X-Hook-Secret header to confirm that this webhook subscription is indeed expected.
right?
Yes, and I was doing that. The thing was that it would throw a 500 error if the X-Hook-Secret header wasn’t included (i.e. in event requests). Thus, when Asana sent a test event, it returned an error, and it deleted the webhook.