Youtube api v3在上传过程中抛出异常

时间:2014-10-17 09:26:05

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

使用youtube api v3上传视频:

  

错误导致上传无法完成。该服务youtube引发了异常:Google.GoogleApiException:Google.Apis.Requests.RequestError后端错误[503]错误[消息[后端错误]位置[ - ]原因[backendError]域[全局]]在Microsoft.Runtime.CompilerServices Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Google.Apis.Upload.ResumableUpload 1上的Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)中的Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(任务任务)中的.TaskAwaiter.ThrowForNonSuccess(任务任务) .d__e.MoveNext()在c:\ code \ google.com \ google-api-dotnet-client \ default \ Tools \ Google.Apis.Release \ bin \ Debug \ test \ default \ Src \ GoogleApis \ Apis [Media] \ Upload \ ResumableUpload.cs:第459行

这个例外。我没有它想要的ida。当我进入调试时,它说:

  

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

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

  

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

它说无法找到 GoogleClientSecrets.cs

enter image description here

我该如何解决?

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

我试过 this但结果相同

1 个答案:

答案 0 :(得分: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

相关问题