javascript - 400 Bad Request on Youtube API Update using AngularJS -
im trying update video's metadata using youtube api v3 in angularjs app. able upload video using insert.
i had unlimited problems trying set video metadata @ same time uploading , kind of determined wasn't going happen, unless can tell me differently. alternative set metadata using videos update action of api https://developers.google.com/youtube/v3/docs/videos/update.
i'm recieving 400 (bad request)
{ "error": { "errors": [ { "domain": "global", "reason": "badcontent", "message": "unsupported content type: application/json;charset=utf-8" } ], "code": 400, "message": "unsupported content type: application/json;charset=utf-8" } }
heres $http request
$http({ method: "put", url: "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,id", headers: { authorization: 'bearer ' + my_google_token }, data: { id: "my_video_id", snippet: { title: "my video title", description: "my video description", tags: ['my','videos','tags'], categoryid: '17' } } }).then(function(response){ console.log('success'); },function(error){ console.log(error); });
the correct answer not use $http , instead use google provided library youtube uploading in javascript.
although confusing, api reference/instructions page here: https://developers.google.com/youtube/v3/code_samples/javascript#upload_video
those code files can found here on github: https://github.com/youtube/api-samples/tree/master/javascript
Comments
Post a Comment