I'm trying to use Youtube API for my project. Here is my problem.
I have a array of video titles and trying to put them in to my playlist. I created a new playlist and got a playlist id, I got video_id from video title using search api. I used for loop to put videos to my playlist. Some of them are working, but some of them are getting 500 error.
I checked the error and checked that the I got video ID right, and when I tried individually with the same request, it worked.
I tried several method like giving delay to the api request, axios interceptors etc
"error": {
"code": 500,
"message": "Internal error encountered.",
"errors": [
{
"message": "Internal error encountered.",
"domain": "global",
"reason": "backendError"
}
],
"status": "INTERNAL"
}
}
Here is the for loop.(logic: get videoId from videoList(It's a array of video titles)=> put it in my playlist)
for (let i = 0; i < videoList.length; i++) {
params.q = checkValue[i];
await searchVideo(params).then((res) => {
try {
addToPlayList(playlistId, res.items[0].id.videoId);
} catch (error) {
console.log(error);
}
});
}
Here is my axios code
baseInstance
.post(
`https://www.googleapis.com/youtube/v3/playlistItems?&part=snippet&resource.snippet.playlistId=${playlistId}&resource.snippet.resourceId.videoId=${vid}&resource.snippet.resourceId.kind=youtube%23video`
)
Any idea what can be the problem?