Hi I am new to the asana api . I am using the code provided from the doc references but i am getting this error Error creating webhook:
{
errors: [
{
message: ‘The remote server which is intended to receive the webhook responded with an incorrect status code: 502’,
help: ‘For more information on API status codes and how to handle them, read the docs on errors: Errors’
}
]
}
\i am trying to get a single projects details from asana but so far have had no luck.
below is my code
Hi @swasteer - I moved your post to the Developers & API forum so you can get more technical responses. A 502 error probably means your haven’t established your server properly (i.e., not an issue with the code you posted).
The 502 error you’re seeing is being generated by the server at your targetUrl. The Asana webhook system is trying to establish the webhook “handshake” to verify your server, and your server is returning a 502. This could be when it sending a POST to send the X-Hook-Secret header to establish the secret to use, or sending the initial X-Hook-Signature header. In either case, Asana is expecting a 200 response from your server and it is receiving a 502 instead.
I recommend using Postman to test sending messages to your ngrok endpoint and seeing what your server is returning.
I’m glad you got it working! It is strongly recommended you store the secret passed by the X-Hook-Secret header in the initial handshake to validate events. After the initial handshake, every webhook event includes an X-Hook-Signature header that is a hash created with the secret. Take a look at the sample Node.js app to see an example of using the crypto library to validate the webhook payload.
One thing to note, the example application stores the secret in a global variable, which will be lost when the server restarts. Your application should securely store the secret so it is persisted across server restarts. Also, keep in mind a unique secret is generated for every webhook registered.