I am trying to create webhook but every time getting below error /
{“errors”:[{“message”:“The remote server did not respond with the handshake secret.”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}/
My Code is something like this
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://app.asana.com/api/1.0/webhooks’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, “resource=TaskID&target=targeturlforwebhook”);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers = ‘Authorization: Bearer <ASANA_PERSONAL_ACCESS_TOKEN>’;
$headers = ‘Content-Type: application/x-www-form-urlencoded’;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
On targeturlforwebhook i created one function which send header back to asana for handshake request. code of that function is something like this
public function webhookfunction()
{
if (!empty($headers[‘X-Hook-Secret’]))
{
header(“X-Hook-Secret:”.$headers[‘X-Hook-Secret’]);
header(“HTTP/1.1 200 OK”);
exit;
}
}
But still getting error. Please help me. Couldn’t understand what’s wrong.
Thanks in advance.