Search code examples
node.jsyoutube-apiyoutube-data-api

YouTube Live Webhook Callback Content Empty


This is my callback endpoint for the pubsubhub' for YT Live, and it is getting requests from YouTube when I go live, but it's output is empty.

server.post('/yt_webhook', async function(req,res){
    console.log('in post');
    console.log(req.read());
    console.log(req.body);
    console.log(req.query);
    res.status(200);
    res.send();
})

the output for this is

in post
null
{}
{}

when the documentation states that it should be an XML formatted thing of youtube videos. Searching through the full request object I see nothing pointing to that.


Solution

  • Using express-xml-bodyparser as middleware does the trick. Now I have:

    var xmlbodyparser = require('express-xml-bodyparser');
    server.use(xmlbodyparser())
    server.post('/yt_webhook', async function(req,res){
        console.log(req.body);
        res.status(200);
        res.send();
    })