Webhooks with Contentful and node
The contentful-webhook-server
does not parse the req so that would explain why it does not deliver the body to you in the callback.
Your server seem to be correct but it seems that contentful has a custom json type that is not recognized by the type-is
library.
the content-type looks like 'application/vnd.contentful.management.v1+json'
your server will probably work if you make body-parser
accept this custom content type. For example :
app.use(bodyParser.json({type: 'application/*'}));
If this works, you could be more specific on the accepted type.
For the record :
typeis.is('application/vnd.contentful.management.v1+json', ['json'])=> false
An easier option is to modify the custom Content-Type
since we know it actually returns JSON
. Just stick this somewhere above the bodyParser
app.use(function(req, res, next) { if (req.headers['content-type'] === 'application/vnd.contentful.management.v1+json') req.headers['content-type'] = 'application/json'; next();});