I'm using YouTube API to upload video to the YouTube sever. The video uploading shows the progress of 100% and then it give error as "The remote server returned an error: (403) Forbidden". I'm using .net 3.5 framework. If i'm using a windows form to upload the video, the video upload successfully but if i'm using windows service it give error after showing progress of 100%. Does anybody has face those issue. could any one explain how to resolve this issue.
Code:
Video newVideo = new Video();newVideo.Title = "TestFeed";
newVideo.Tags.Add(new MediaCategory("Tech", YouTubeNameTable.CategorySchema));newVideo.Keywords = "TestFeed";newVideo.Description = "TestFeed_";newVideo.YouTubeEntry.Private = false;newVideo.YouTubeEntry.setYouTubeExtension("location", "Delhi, India");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(@"E:\Publish\mp4\TestFeed_137_52_512.mp4", "video/mp4");
AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" + "YTUser_Name" + "/uploads"); link.Rel = ResumableUploader.CreateMediaRelation; newVideo.YouTubeEntry.Links.Add(link);
GDataCredentials Credentails = new GDataCredentials(Username, Password); string AppName = Application.ProductName; ClientLoginAuthenticator cAuth = new ClientLoginAuthenticator(AppName, ServiceNames.YouTube, Credentails); cAuth.DeveloperKey = DeveloperKey;
ResumableUploader RSUpload = new ResumableUploader(10); RSUpload.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(RSUpload_AsyncOperationCompleted); RSUpload.AsyncOperationProgress += new AsyncOperationProgressEventHandler(RSUpload_AsyncOperationProgress);
UserState State = new UserState(); State.RetryCounter = 0;
RSUpload.InsertAsync(cAuth, newVideo.YouTubeEntry, State);
void RSUpload_AsyncOperationCompleted(object sender, AsyncOperationCompletedEventArgs e) { if (e != null) { UserState u = e.UserState as UserState;
if (u != null) { if (e.Cancelled) {
}
//After complete uploading video always stuck here.... else if (e.Error != null) { console.writeLine("Error - " + e.error.toString());
} else {
console.writeLine("Uploaded!!!!");
}
}}
Thanks,
Ajitpal Singh
-- You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/xoSHAR78gasJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment