Reputation: 79
Here is what I want to do:
Naturally, I'm using the native Podio webhooks. I made a hook for item.create, item.update, and item.delete. The external URLs are correct and clicking the "verify" button sends a successful call to the external app.
However, none of the actions actually work. I've created, changed, and deleted items - nothing. Only clicking the "verify" button causes any communication with the external app.
What are some common reasons why this might not be working?
Upvotes: 1
Views: 962
Reputation: 5467
Here's how I managed to verify my Node.JS webhook endpoint and make it active using Express.JS
:
const express = require("express");
const app = express();
const https = require('https');
app.use(express.urlencoded());
app.use(express.json());
app.post('/', function(request, response){
console.log( "POST", request.body);
// VERIFICATION >>
const postData = JSON.stringify({ code: request.body.code });
const options = {
hostname: 'api.podio.com',
port: 443,
path: '/hook/' + request.body.hook_id + '/verify/validate',
method: 'POST',
headers: {
'content-type': 'application/json',
'accept': 'application/json'
}
};
const req = https.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log(`BODY: ${chunk}`);
});
res.on('end', () => {
console.log('No more data in response.');
});
});
req.on('error', (e) => {
console.error(`problem with request: ${e.message}`);
});
req.write(postData);
req.end();
// << VERIFICATION
response.send(request.body);
});
app.listen(443);
Upvotes: 1
Reputation: 2013
Have you activated that webhook? From Podio documentation https://developers.podio.com/examples/webhooks
Before your webhooks becomes active the URL must be verified. Immediately after the webhooks is created a hook.verify notification is sent to the URL endpoint. The endpoint must then return the code to the validation operation. Events will only be sent to the endpoint after a completed verification.
Example with command line curl:
Please remember to inject correct access_token
, hook_id
and verification_code
curl -H "Content-Type: application/json" -H "Authorization: OAuth2 [access_token]" -X POST -d "{'code': [verification_code]}" https://api.podio.com/hook/[hook_id]/verify/validate
Upvotes: 2