Error in handshake response while creating webhooks ('You should specify one of resource')

Hi,
I am trying to create a webhook using django.

asana_url = asana-webhook-url
data = {“data”: {“resource”: task_id,
“target”: https://my-webhook-url/ticket_id}}
header = {“Authorization”: "Bearer " + token}
response1 = requests.post(url=asana_url, data=json.dumps(data), headers=header)

API(method=POST) is called by asana → my-webhook-url/ticket_id
I got the hook secret key as follows,

secret = request.META[‘HTTP_X_HOOK_SECRET’]

(handshake)I post back the secret key in headers to the same asana url

asana_url = asana-webhook-url
header = {“X-Hook-Secret”: secret, “Authorization”: "Bearer " + token}
data = {“data”: request_data}
response = requests.post(url=asana_url, data=data, headers=header)
return Response(data=response, status=status.HTTP_200_OK)

Now the variable response gives me an error with status_code=400 with error,
{“errors”:[{“message”:“You should specify one of resource”,“help”:“For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”}]}

Hmm, I’m not sure why you’re seeing that specific error message, because your original post request does look like it has the right body and there’s nothing simple like “resource” being misspelled or anything. At first glance this seems like it should work.

One thing I do notice is that the response to the webhook looks incorrect to me in that you don’t have to re-post to Asana but rather return the response with the header. In other words, I think handling the handshake should look less like this:

asana_url = asana-webhook-url
header = {“X-Hook-Secret”: secret, “Authorization”: "Bearer " + token}
data = {“data”: request_data}
response = requests.post(url=asana_url, data=data, headers=header)
return Response(data=response, status=status.HTTP_200_OK)

and should be something more like this:

header = {“X-Hook-Secret”: secret}
return Response(data=response, status=status.HTTP_200_OK, headers=header)

If you’d like an example, take a look here at a script we have to show how this is done

Thank you @Matt_Bramlage. I tried your solution and it worked for me. I missed to add headers in the handshake response .