【问题标题】:Youtube api v3 throws an exception during uploadYoutube api v3 在上传过程中抛出异常
【发布时间】:2014-12-12 20:30:46
【问题描述】:

使用 youtube api v3 上传视频会抛出:

一个错误导致上传无法完成。服务 youtube 已引发异常:Google.GoogleApiException: Google.Apis.Requests.RequestError Backend Error [503] Errors [ Message[Backend Error] Location[ - ] Reason[backendError] Domain[global] ] at Microsoft.Runtime.CompilerServices .TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Google.Apis.Upload.ResumableUpload1.d__e c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis\Apis[Media]\Upload 中的 .MoveNext() \ResumableUpload.cs:459 行

这个例外。我不知道它想要什么。当我要进行调试时,它会说:

找不到 GoogleClientSecrets.cs,然后找不到 NewtonsoftJsonSerializer.cs 等等。

我已经使用了this code for upload,但它有错误.. 所以我正在使用这个:full code in pastebin。在

var secrets = GoogleClientSecrets.Load(stream).Secrets;

它说找不到 GoogleClientSecrets.cs

我该如何解决?

client_secrets.json 一切正常,并且我的应用程序已经在 console.google.com 中注册了我昨天没有上传,但是 1 小时后它抛出了这个异常.. WTF需要吗?

我试过了 this 但结果相同

【问题讨论】:

  • 你发现问题了吗?

标签: c# asp.net api youtube youtube-api


【解决方案1】:

这个简单的代码可以工作,

Video newVideo = new Video();

newVideo.Title ="My Test Movie";
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", 
  YouTubeNameTable.DeveloperTagSchema));

newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
// alternatively, you could just specify a descriptive string
// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");

newVideo.YouTubeEntry.MediaSource = new MediaFileSource("c:\\file.mov",
  "video/quicktime");
Video createdVideo = request.Upload(newVideo);

参考:https://developers.google.com/youtube/2.0/developers_guide_dotnet?csw=1#Direct_Upload

【讨论】:

    猜你喜欢
    • 2014-11-03
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 2016-03-30
    • 2012-10-07
    • 2016-02-17
    • 2016-03-23
    • 1970-01-01
    相关资源
    最近更新 更多