C# 使用其API将视频上载到YouTube时出错
我已经创建了API密钥并将其用作开发人员密钥。将视频上载到YouTube时出现此错误:C# 使用其API将视频上载到YouTube时出错,c#,youtube-api,C#,Youtube Api,我已经创建了API密钥并将其用作开发人员密钥。将视频上载到YouTube时出现此错误: Google.GData.Client.GDataRequestException was unhandled by user code HResult=-2146233088 Message=Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads Source=G
Google.GData.Client.GDataRequestException was unhandled by user code
HResult=-2146233088
Message=Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads
Source=Google.GData.Client
ResponseString=<?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:validation</domain><code>invalid_value</code><location type='xpath'>media:group/media:category[@scheme='http://gdata.youtube.com/schemas/2007/categories.cat']/text()</location></error></errors>
StackTrace:
at Google.GData.Client.GDataRequest.Execute()
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
at Google.GData.Client.GDataGAuthRequest.Execute()
at Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
at Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)
at Google.GData.YouTube.YouTubeService.Upload(String userName, YouTubeEntry entry)
at Google.YouTube.YouTubeRequest.Upload(String userName, Video v)
at Google.YouTube.YouTubeRequest.Upload(Video v)
at WebApplication1.WebForm2.UploadVideoToYoutube() in c:\Users\Ajay.Kumar\Documents\Visual Studio 2012\Projects\WebApplication1\WebApplication1\WebForm2.aspx.cs:line 87
at WebApplication1.WebForm2.Page_Load(Object sender, EventArgs e) in c:\Users\Ajay.Kumar\Documents\Visual Studio 2012\Projects\WebApplication1\WebApplication1\WebForm2.aspx.cs:line 21
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at Google.GData.Client.GDataRequest.Execute()
InnerException:
我使用下面的代码上传视频,并使用开发者密钥作为API密钥(浏览器)
你试过阅读吗?我对开发人员密钥感到困惑。它是API密钥吗?
YouTubeRequestSettings settings = new YouTubeRequestSettings("My Channel", devKey, username, password) { Timeout = -1 };
YouTubeRequest request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = Title;
newVideo.Description = Description;
// newVideo.Private = true;
newVideo.YouTubeEntry.Private = false;
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/mp4");
Video CreateVideo = request.Upload(newVideo);