How do I use the youtube v3 api to set the youtube live broadcast Tags and youtube live broadcast CategoryID on youtube Live Broadcast. In JS code?

I am using JS to create a youtube live stream and then bing it to a new live broadcast. However I want to set the broadcasts Category and TAGS, but adding those values to the snippet seem to be ignored. So i am now trying to trigger this with a Update and while i can get the title to change the Tags and category ID still seem to get ignored.

here is my update code


function updateYoutubeBroadcast(broadcastResponse,accessToken) {
    var updateData = {
        "id": broadcastResponse.id,
        "snippet": {
            "title": "Streamer Toolbox lives 3",
            "categoryId": "24", // Gaming
            "tags": ["test", "live", "prestage"],
            "scheduledStartTime": "2025-01-15T01:54:27Z" // Or whatever your current start time is
        }
    };

    $.ajax({
        url: 'https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet',
        type: 'PUT',
        headers: {
            'Authorization': 'Bearer ' + accessToken,
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(updateData),
        success: function(updateResponse) {
            console.log('Broadcast updated:', updateResponse);
        },
        error: function(xhr, status, error) {
            console.error('Failed to update broadcast:', xhr.responseText);
        }
    });    
}

How can this be done? if i go into the Youtube Studio, i can see the pending Live stream and edit its Tags and category with no issue. Any suggestions or pointers would be appreciated.

Upvotes: 0

Views: 8

Answers (0)

Related Questions