I visited the Youtube Data v3 API docs to know about how to upload videos using the client library
I got to this page
https://developers.google.com/youtube/v3/docs/videos/insert
but it doesn't seem to explain where to put the video in the request And Also API explorer just gives the code for request, it doesn't let me execute the code for that page
I also read the resource structure page but didn't find where to put the video
https://developers.google.com/youtube/v3/docs/videos#resource
here's my current code
let req = gapi.client.youtube.videos.insert({
part: 'snippet,status',
snippet: {
title: "Test Video",
description: "Test Description",
categoryId: 28,
defaultLanguage: 'en',
defaultAudioLanguage: 'en'
},
status: {
privacyStatus: "private"
},
});
console.log(req)
try {
req.execute(function (response) {
console.log(response);
});
} catch (e) {
console.error(e);
}
Now, where do I put the video in the request? do I have to put that as buffer? I am fetching video from fetch API for uploading via API
and whenever I run the code I get the Error: 400 in the console
code: 400
data: [{…}]
error: {code: 400, data: Array(1), message: 'Request contains an invalid argument.'}
message: "Request contains an invalid argument."
so can you provide a working example of uploading a video using the client library that is fetched from the fetch API and show to structure the request body when using the client library?