Seems like Youtube v3 playlist item insertion API (https://developers.google.com/youtube/v3/docs/playlistItems/insert) is responding with a wrong error message even though the video is successfully inserted into the playlist.
I went through the documentation and also searched for similar issues but have no clue why the youtube.playlistItems.insert call is failing.
I'm using googleapis node client to make this request. Here goes the code snippet:
let oauthConfig = config.oauthConfig;
let oAuthClient = new Google.auth.OAuth2(oauthConfig.clientId, oauthConfig.clientSecret);
oAuthClient.setCredentials({access_token: credentials.accessToken, refresh_token: credentials.refreshToken});
let youtubeApi = Google.youtube({version: 'v3', auth: _getOauthClient(_channel.credentials)});
youtube.playlistItems.insert({
part: 'snippet',
resource: {
snippet: {
playlistId: playlist.id,
resourceId: {
kind: 'youtube#video',
videoId: video.id
}
}
}
}, function (err) {
});
Here the callback method receives
404 Video not found.
at Request._callback (<proj_dir>/node_modules/google-auth-library/lib/transporters.js:85:15)
at Request.self.callback (<proj_dir>//node_modules/google-auth-library/node_modules/request/request.js:187:22)
The doc mentioned above says,
notFound (404) - videoNotFound - The video that you are trying to add to the playlist cannot be found. Check the value of the videoId property to ensure that it is correct.
Calling the above code with playlist: PL4D56EB46ED904B8A and video: 4HlpCEEwdxk has resulted in this error, but both video and playlist has public visibility and seems correct. More surprisingly the video uploaded correctly and was inserted into the correct playlist (I verified by visiting https://studio.youtube.com/video/4HlpCEEwdxk/edit/basic), so it seems like a false error.
The same code works for different video without any error though. I'm clueless about what is wrong here. Any help is much appreciated. Thanks