Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Expo React-Native Youtube video upload using Fetch()

$
0
0

I am trying to upload a video on youtube using the V3 Youtube.video.insert API method. When I call the method I get the following error message: Bad request: Request contains an invalid argument.. Despite the error message my upload still appears in my personal YouTube account under My Videos. I am new to React Native and I'm struggling to understand the Youtube API docs, could someone please explain to me what I'm doing wrong or how could I fix it?

This is my current request:

let response = await fetch('https://youtube.googleapis.com/youtube/v3/videos?key='+ API_KEY,        {          method: 'POST',          headers: {'Authorization': 'Bearer '+ accessToken,'Accept': 'application/json','Content-Type': 'application/json'          },          body: JSON.stringify({            part: 'id,snippet,status',            notifySubscribers: false,            requestBody: {              snippet: {                title: 'YouTube Upload Test',                description: 'Testing YouTube upload',              },              status: {                privacyStatus: 'private',              },            },            media: {              body: 'file:///data/user/0/host.exp.exponent/cache/ExperienceData/Camera/video.mp4',            }          })        }      );

I tried taking everything out from body: but I got the same response.

Here are the links that I am using trying to understand:https://developers.google.com/youtube/v3/docs/videos/inserthttps://github.com/googleapis/google-api-nodejs-client/blob/master/samples/youtube/upload.js

UPDATE:

Ok, I think I figured out but I still don't know how can I attach the video file... this is my code now:

let response = await fetch('https://youtube.googleapis.com/youtube/v3/videos?part=snippet&part=status&key='+ API_KEY,    {      method: 'POST',      headers: {'Authorization': 'Bearer '+ accessToken,'Accept': 'application/json','Content-Type': 'application/json'      },      body: JSON.stringify({        snippet: {          title: "This is the title",          description: "This is the description.",        },        status: {          privacyStatus: 'private',        }      }),              }  );

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>