API Webhook Create Not Working?

Hi,

Im hoping someone can help me. Im building an application that will use the Webhook API. I have followed the documentation to the letter and as of a few days ago had everything working correctly but for some reason something has changed and I cant understand what/why.

So My application is designed to check for the existence of a local reference of a Project and where there isn’t one, create one and then create a Webhook for that project with Asana. the application makes the request to Asana as per the documentation and my application authenticates the request for a Webhook by returning the secret header… Asana then responds with the expected response, showing a unique Webhook ID and the creation date, plus a few other properties… exactly like the docs.

However… If i then use postman to request all Webhooks created for projects in a given workspace…nothing is found. If i try and find the webhook directly using the ID that was returned from Asana, nothing is found.

Its as if the Webhook API is accepting the request, authorising the request and then failing to setup the Webhook?

Any pointers or help on this would be great, Im really stuck and its halted progress on my project unfortunately.

Example of the return from Webhook create request formatted as per the documentation:

{  
  "data": {
     "id": 112233445566778899,
     "target": "https://PROJECT TARGET URL AS PASSED IN",
     "active": true,
     "created_at": "2017-05-09T08:38:39.503Z",
     "last_failure_at": null,
     "last_failure_content": "",
     "last_success_at": null,
     "resource": {
         "id": 282152651586423,
         "name": "Asana Test"
     }
   }
}

Example Message when looking for the Webhook Directly

https://app.asana.com/api/1.0/webhooks/112233445566778899

{
    "errors": [
    {
        "message": "webhook: Unknown object: 112233445566778899",
        "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"
    }
    ]
}

What am I missing?

Thanks in advance,

Hi @Olly_Warren,

From reading your post is sounds like you’re doing things correctly.
From my own experience, I am able to request a listing of all webhooks for given workspace using Asana’s NodeJS client library by using client.webhook.getAll(<workspaceId>)

If you’re using NodeJS/MongoDB, May I suggest you take a look at Asana Webhooks Manager on Github, it’s a starting point application I recently put on github, to assist use cases likes yours, and save others valuable time

Eyal

1 Like

make that client.webhooks.getAll(workspaceId) :slight_smile:

Hey @Olly_Warren, after the Asana API sends the x-hook-secret and you send it back as specified in the documentation it will actually send an x-hook-signature back after in the header that you have to send back as well. So pretty much the same step that you performed with the x-hook-secret but with the x-hook-signature. They fail to explain this in the documentation.

@Olly_Warren take a look here: https://github.com/EyalRonel/asana-webhooks-manager/blob/master/controllers/EventsController.js

it will help you see the general flow of things

Hi,
Here is my code .Really appreciated your support .

        [System.Web.Http.HttpPost]
        public String TargetWebHook()//Stream data
        {
            HttpResponseMessage _response = new HttpResponseMessage();
            IRestResponse response;
            try
            {
                //TODO
                var headers = Request.Headers;

                if (headers.AllKeys.Contains("X-Hook-Secret"))
                {
                    var key = headers["X-Hook-Secret"];
                    _response.Headers.Add("X-Hook-Secret", key);
                    
                }
                else if (headers.AllKeys.Contains("X-Hook-Signature"))
                {
                    //Handle Event .Will do later
                    var Secretkey = headers["X-Hook-Signature"];
                    _response.Headers.Add("X-Hook-Signature", Secretkey);                    

                }
                _response.StatusCode = HttpStatusCode.OK;
             
                return _response;//Json("OK", JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
                _response.StatusCode = HttpStatusCode.BadRequest;
                _response.ReasonPhrase = ex.Message;
                return _response;
            }
           
        }
   Thanks .

Hey @Ravinder_Rana, @Brett_Wright

Look like I’m facing the same issue. I’m able to successfully register webhook with sending handshake with x-hook-secret & x-hook-signature

But when I try to check whether it’s successfully registered or not with
https://app.asana.com/api/1.0/webhooks/{webhook_gid}

{
    "errors": [
        {
            "message": "webhook: Not a recognized ID: *******",
            "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 also tried creating and deleting a task but I’m not getting anything in webhook.

Hey @dedania.dipen,

Check this out:

Asana is moving to string IDs [Updated with revised timeline] - #11 by Joe_Trollo

@Diakoptis Aggred .

Aside to @dedania.dipen try this through polling mechanism ,May be it help for you .
Thanks .