C#Youtube api V3-值不能为null错误异常
我正在使用C#Youtube客户端API v3将字幕上传到我的视频中。上传视频效果很好(所以我认为在身份验证和凭证方面没有问题)。我尝试过类似问题中推荐的各种可能的选择,但没有一个对我有效 我的工作范围如下:C#Youtube api V3-值不能为null错误异常,c#,youtube,youtube-api,C#,Youtube,Youtube Api,我正在使用C#Youtube客户端API v3将字幕上传到我的视频中。上传视频效果很好(所以我认为在身份验证和凭证方面没有问题)。我尝试过类似问题中推荐的各种可能的选择,但没有一个对我有效 我的工作范围如下: YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtubepartner string zFile = @"subs.srt";
YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtubepartner
string zFile = @"subs.srt";
using (var fileStream = new FileStream(zFile, FileMode.Open))
{
Caption cap = new Caption();
cap.Snippet = new CaptionSnippet();
cap.Snippet.VideoId = "_VIDEO_ID";
cap.Snippet.Language = "en";
cap.Snippet.Name = "Test";
cap.Snippet.IsDraft = false;
const int KB = 0x400;
var minimumChunkSize = 256 * KB;
CaptionsResource.InsertMediaUpload req = youtubeService.Captions.Insert(cap, "snippet" , fileStream, "*/*");
req.Sync = true;
req.ProgressChanged += videosInsertRequest_ProgressChanged;
req.ChunkSize = minimumChunkSize * 8;
//req.ResponseReceived += videosInsertRequest_ResponseReceived;
IUploadProgress result = req.Upload();
}
System.ArgumentNullException: Value cannot be null.
Parameter name: baseUri
编辑:(根据一条注释中的要求,在下面添加了与服务初始化相关的代码)
代码的其他重要部分如下所示:
YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtubepartner
string zFile = @"subs.srt";
using (var fileStream = new FileStream(zFile, FileMode.Open))
{
Caption cap = new Caption();
cap.Snippet = new CaptionSnippet();
cap.Snippet.VideoId = "_VIDEO_ID";
cap.Snippet.Language = "en";
cap.Snippet.Name = "Test";
cap.Snippet.IsDraft = false;
const int KB = 0x400;
var minimumChunkSize = 256 * KB;
CaptionsResource.InsertMediaUpload req = youtubeService.Captions.Insert(cap, "snippet" , fileStream, "*/*");
req.Sync = true;
req.ProgressChanged += videosInsertRequest_ProgressChanged;
req.ChunkSize = minimumChunkSize * 8;
//req.ResponseReceived += videosInsertRequest_ResponseReceived;
IUploadProgress result = req.Upload();
}
System.ArgumentNullException: Value cannot be null.
Parameter name: baseUri
执行上述代码时得到的异常如下:
YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtubepartner
string zFile = @"subs.srt";
using (var fileStream = new FileStream(zFile, FileMode.Open))
{
Caption cap = new Caption();
cap.Snippet = new CaptionSnippet();
cap.Snippet.VideoId = "_VIDEO_ID";
cap.Snippet.Language = "en";
cap.Snippet.Name = "Test";
cap.Snippet.IsDraft = false;
const int KB = 0x400;
var minimumChunkSize = 256 * KB;
CaptionsResource.InsertMediaUpload req = youtubeService.Captions.Insert(cap, "snippet" , fileStream, "*/*");
req.Sync = true;
req.ProgressChanged += videosInsertRequest_ProgressChanged;
req.ChunkSize = minimumChunkSize * 8;
//req.ResponseReceived += videosInsertRequest_ResponseReceived;
IUploadProgress result = req.Upload();
}
System.ArgumentNullException: Value cannot be null.
Parameter name: baseUri
请注意,我已经尝试了代码段,状态也不可用
感谢社区的支持。我想你需要检查一下
CaptionsResource.InsertMediaUpload req = youtubeService.Captions.Insert(cap, "snippet" , fileStream, "*/*");
看看这个帖子:你在哪里初始化YouTube服务?你能给出代码吗?只是在编辑部分添加了与YouTube服务初始化相关的代码。事实上,我以前看过那个线程,甚至在那个线程中,他最终也出现了与我相同的错误,这没有帮助。我还提到,我尝试了“snippet”和“snippet,status”,但在这两种情况下都会出现相同的错误。