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

Uploading large video file(mp4, 130 megabyte) to YouTube with ResumableUploader

$
0
0

I have following code:

var newVideo = new Video{    Title = Path.GetFileNameWithoutExtension(file),    Keywords = keywordstring,    Description = "Some Description"};newVideo.Tags.Add(new MediaCategory(projectSettings.Category.ToString(), YouTubeNameTable.CategorySchema));newVideo.YouTubeEntry.Private = false;newVideo.YouTubeEntry.MediaSource = new MediaFileSource(file, "video/quicktime");        AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" + Credentials.UserName.Split('@')[0] +"/uploads");        link.Rel = ResumableUploader.CreateMediaRelation;        newVideo.YouTubeEntry.Links.Add(link);        ResumableUploader ru = new ResumableUploader(10);        GDataCredentials credentials = new GDataCredentials(Credentials.UserName, Credentials.Pass);        Authenticator youTubeAuthenticator = new ClientLoginAuthenticator("OnlineVideoDrive",ServiceNames.YouTube, credentials);        youTubeAuthenticator.DeveloperKey = "AIzaSyCdvck_1yrovHGusir2Ddw8KlYvl7rj2LQ";        ru.Insert(youTubeAuthenticator, newVideo.YouTubeEntry);

Evertything seems to be working fine until the last Line

ru.Insert(youTubeAuthenticator, newVideo.YouTubeEntry);

The line throws a WebException:

System.Net.WebException ist aufgetreten.  HResult=-2146233079  Message=Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.  Source=System  StackTrace:       bei System.Net.HttpWebRequest.GetResponse()       bei Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry, String httpMethod)       bei Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry)       bei Google.GData.Client.ResumableUpload.ResumableUploader.Insert(Authenticator authentication, AbstractEntry payload, AsyncData data)       bei Google.GData.Client.ResumableUpload.ResumableUploader.Insert(Authenticator authentication, AbstractEntry payload)       bei LetsPlayHelper.Form1.youtubeBackgroundWorker_DoWork(Object sender, DoWorkEventArgs e) in f:\Project\Form1.cs:Zeile 348.  InnerException: 

I already tried a direct upload with the YouTubeRequest class. Well small Videos are not a problem but larger ones are causing the Request to abort.

Edit: ex.Response.StatusCode and StatusDescription are "BadRequest"

Edit 2 : The whole upload code is running in a BackGroundWorker

Edit 3 : I also tried the YouTubeUploader example with the same error(https://code.google.com/p/google-gdata/wiki/YouTubeUploader)

I grabbed the response with Fiddler

Discovered:

<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidRequestUriException</code><internalReason>Exception message unavailable</internalReason></error></errors>

Viewing all articles
Browse latest Browse all 3712

Latest Images

Trending Articles



Latest Images

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