I am not able to create webhook


#1

Error details are as below ,please suggest .
{
“errors”: [
{
“message”: “Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL”,
“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
}
]
}


#2

The issue is most likely one of two things: either you’re not doing the correct sequence of events to establish the webhook, or it’s an SSL issue.

For the former, make sure you’re precisely following the instructions for establishing a webhook; there is also some discussion of it in this forum thread.

People have also had issues with some SSL certificates and related server settings; see this thread and this thread for some discussion of SSL-related problems.


#3

Make also sure not to use H2 (http2) – that was my problem – not the certificate as I thought.


#6

Request/Response

Steps
1. Creating webhook:-
var client = new RestClient(“https://app.asana.com/api/1.0/webhooks”);
var request = new RestRequest(Method.POST);
request.AddHeader(“content-type”, “application/x-www-form-urlencoded”);
request.AddHeader(“authorization”, "Bearer key ");
request.AddParameter(“application/x-www-form-urlencoded”, “resource=project_id&target=https://domain.net/AsanaWebhook/TargetWebHook”, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

2. Error:

{
    "errors": [
        {
            "message": "Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL",
            "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"
        }
    ]
}
           
3. Target end point code .

public HttpResponseMessage TargetWebHook()//Stream data
{
            //TODO
            var headers = Request.Headers;
            HttpResponseMessage _response = new HttpResponseMessage();
            if (headers.AllKeys.Contains("X-Hook-Secret"))
            {
                var key = headers["X-Hook-Secret"];
                _response.Headers.Add("X-Hook-Secret", key);
                _response.StatusCode = HttpStatusCode.OK;            
            }
            return _response;//Json("OK", JsonRequestBehavior.AllowGet);

  }

This is exactly what I am doing .


#7

Request/Response

  1. Creating webhook:-
    var client = new RestClient(“https://app.asana.com/api/1.0/webhooks”);
    var request = new RestRequest(Method.POST);
    request.AddHeader(“content-type”, “application/x-www-form-urlencoded”);
    request.AddHeader(“authorization”, "Bearer key ");
    request.AddParameter(“application/x-www-form-urlencoded”, “resource=project_id&target=https://domain.net/AsanaWebhook/TargetWebHook”, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

  1. Error:

{
“errors”: [
{
“message”: “Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL”,
“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
}
]
}

  1. Target end point code .

public HttpResponseMessage TargetWebHook()//Stream data
{
//TODO
var headers = Request.Headers;
HttpResponseMessage _response = new HttpResponseMessage();
if (headers.AllKeys.Contains(“X-Hook-Secret”))
{
var key = headers[“X-Hook-Secret”];
_response.Headers.Add(“X-Hook-Secret”, key);
_response.StatusCode = HttpStatusCode.OK;
}
return _response;//Json(“OK”, JsonRequestBehavior.AllowGet);

}

This is exactly what I am doing .


#8

Your code looks good to me. A few things:

Where you have project_id, you’re putting the actual id of one of your projects and not the literal string project_id, correct?

For your authorization, you’re putting the literal string Bearer, then a space, then your auth key, correct?

Pretty sure you’re doing all of the above, I just wanted to eliminate all possible code issues.

Also, are you able to remotely debug or put some logging and see if your TargetWebHook endpoint is getting hit when you do the initial call? Where is it - is it on Azure or some other server?


#9

First of all thanks Phil for your time .

  1. Yes offcourse project_id is actual id .
  2. Secondly for authorization Bearer is the format and key means my key which i generated in Asana .
  3. It is published on Azure and url is in format https://domain.net and yes i am able to hit TargetWebHook both on published and local as well .

Thanks .


#10

Ahh wait, is your webhook code also handling receipt of an X-Hook-Signature webhook? As soon as you respond to the initial X-Hook-Secret webhook, they will send an X-Hook-Signature one and you have to respond to that one as well.


#11

Hello Phil,

Request 1
https://app.asana.com/api/1.0/webhooks
It hits the target url with “X-Hook-Secret” and Respond 200 .I have added “X-Hook-Signature” but it does’t hit again with “X-Hook-Signature” .
Finally request 1 return with

{“errors”:[{“message”:“Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL”,“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”}]}

Moreover my SSL Details are

Code
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);

}

Thanks .