How do I change the title and description while creating playlist using the YouTube API?

311 views Asked by At

I am trying to change the playlist default name and description by adding the fields in playlist_updates.html, but I am unable to change it.

Here is the reference for the YouTube API: https://developers.google.com/youtube/v3/code_samples/javascript#create-a-playlist

1

There are 1 answers

0
Vinay On

You need to use the update API in order to update playlists.You need to get the playlist ID of the playlist (which you get from insert's results) and update it like this

var request = gapi.client.youtube.playlists.update({
  part: 'id,snippet',
  resource: {
    id: '{insert playlist id here}',
    snippet: {
      title: 'New Playlist Title',
      description: 'Well this is a new description hope you like it :)'
    }
  }
});

Then execute your request

request.execute(function(response) {
    var result = response.result;
    if(result){
      alert('updated playlist id : '+  result.id + ' with title: '+ result.snippet.title + ' and description : ' + result.snippet.description);
    } else {
      alert('some error');
    }
});