I'm attempting to receive a webhook from a 3rd party. Whilst I can see the content-length > 0, console.logging the req.body simply yields {}. The request is being sent to the route '/v2/wtevr/report/wtevr'.
These are the headers received from the webhook POST request:
accept: '*/*',
'accept-encoding': 'gzip, deflate',
'user-agent': 'rest-client/2.0.2 (linux-gnu x86_64) ruby/2.5.3p105',
'content-type': 'application/vnd.wtevr.wtevr.leadwebhook+json;version=0.0.2',
'content-length': '254',
host: 'api.mysite.co.uk'
I'm using Express' body-parser to parse the response. According to the Express docs, body-parser supports automatic inflation of 'gzip' and 'deflate' encodings. I've specified the content-type to catch the request and unzip it, but it's not working. This is what my code looks like:
app.use(
function(req, res, next) {
if (req.url === '/v2/wtevr/report/wtevr') {
next();
}
}
)
app.use(bodyParser.json({type: ['application/json', 'application/vnd.wtevr.wtevr.leadwebhook+json;version=0.0.2']}));
app.use(bodyParser.urlencoded({ extended: true }));
Does anyone know how I can parse/view the body?