Something wrong with create webhook, please help

Hi Asana,

I’m new in webhooks generally.

I have problem with CreateWebhook, i tried install Asan php sdk to Lumen framework (installed okay).
Token created in console (created app and there created token) - looks ok

Did this steps:

$client = Client::accessToken(‘token’);
$result = $client->webhooks->createWebhook([
‘resourse’ => ‘xxxxx’, //project_id got from url “app.asana .com/0/xxxxx/list”
‘target’ => ‘mydomain/api/tasks’
],
[‘opt_pretty’ => ‘true’]
);
But each time got error “Invalid Request”

For this start to checking/debug Requests inside SDK how it works and found answer on request “this message (“You should specify one of resource”)”

Also tried using just Curl also problem
curl -H "Authorization: Bearer xxxxxxxxxxtoken
-X POST https://app.asana.com/api/1.0/webhooks
-d “resource=project_id”
-d “target=mydomian/api/tasks”

Error is:
“message”: “The remote server which is intended to receive the webhook responded with an incorrect status code: 405”

What i need from webhooks

  • Asana calls our system via webhook using “skinny” events (see Asana API docs).
  • These events are put into a queue (a table you will create).
  • We then pull the details (projects/tasks/assignments/status) of those queued skinny events using Asana REST API.
  • Data is stored in the database.
  • Events are CRUD on projects, tasks, users, etc.

What is wrong, what i do wrong, please help me with this…

p.s. sorry for my english

Thank you,
Taras

Hi,

In the documentation, did you read the part about the handshake mechanism? Your server might not be answering properly to the handshake Asana sends.

Hello Bastien_Siebman,

Thank you for answer, sorry for long response.
How I can check handshake mechanism from my server?
Can you give some link to doc, will be good with some example?

Thank you,
Taras

Here you go the official doc on handshake

I found info that need send Hook-Secret back

I did it like that ( but i think request don’t come here and lost somewhere with error 405)
“The remote server which is intended to receive the webhook responded with an incorrect status code: 405”

Maybe you give some advice about error 405?

$headers = apache_request_headers();

    // if headers contain X-Hook-Secret, we need to answer with 200

    if (array_key_exists('X-Hook-Secret', $headers)) {

        $xHookSecret = $headers['X-Hook-Secret'];

        // header needs to be resent

        header('X-Hook-Secret: ' . $xHookSecret);

        header("HTTP/1.1 200 OK");

        exit;

    }

Did you try contacting your own server using Postman for example?