2013-10-02 36 views
0

我试图通过C#中的API(不通过客户端)将视频(可恢复)上传到YouTube。YouTube API视频上传解析错误C#

我下面these instructions on using resumable upload protocol

然而,当我这样的尝试,我回去了解析错误。

这里是我的要求:


POST /upload/youtube/v3/videos?uploadType=resumable&part=snippet,status,contentDetails&key={api_key} HTTP/1.1 
Host: www.googleapis.com 
X-upload-content-length: 5346742 
X-upload-content-type: video/* 
Content-type: application/json; charset=UTF-8 
Content-length: 277 
Authorization: Bearer {access_token} 

{ 
    "snippet": { 
    "title": "My video title", 
    "description": "This is a description of my video", 
    "tags": ["cool", "video", "more keywords"], 
    "categoryId": 22 
    }, 
    "status": { 
    "privacyStatus": "public", 
    "embeddable": True, 
    "license": "youtube" 
    } 
} 

这里是回应:


HTTP/1.1 400 Bad Request 
Alternate-protocol: 443:quic 
Content-length: 171 
Via: HTTP/1.1 GWA 
X-google-cache-control: remote-fetch 
Server: HTTP Upload Server Built on Sep 30 2013 10:58:35 (1380563915) 
Date: Wed, 02 Oct 2013 21:38:10 GMT 
Content-type: application/json 

{ 
"error": { 
    "errors": [ 
    { 
    "domain": "global", 
    "reason": "parseError", 
    "message": "Parse Error" 
    } 
    ], 
    "code": 400, 
    "message": "Parse Error" 
} 
} 

人有什么想法?

回答

0

为什么不使用Google GData Youtube Api for .NET?

 string developerkey = "developerKey"; 
     YouTubeRequestSettings settings = new YouTubeRequestSettings("Somethinghere", developerkey, "googleUserName", "googlePassWord"); 
     YouTubeRequest request = new YouTubeRequest(settings); 

     newVideo.Title = "Video Title Here || ArgeKumandan"; 
     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)); 
     // alternatively, you could just specify a descriptive string 
     // newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA"); 

     newVideo.YouTubeEntry.MediaSource = new MediaFileSource(@"D:\video ArgeKumandan.flv", "video/flv"); 

     createdVideo = request.Upload(newVideo); 
+0

ArgeKumandan,我宁愿不使用beta sdk。同样在你给它的例子中,我需要知道用户名和密码。我有一个有效的OAuth2令牌,但没有用户名/密码。如果没有办法让浏览器方法工作,我会使用.NET SDK。 –

1

解析错误是由于与一大T.

写入(使用公测库不监守统一我的选择。.NET 2.0 ..)

+0

gulgi, 我确实尝试了您的建议,但似乎没有任何效果。 我仍然得到相同的回应。 { 错误:{ \t错误:[1] \t \t 0:{ \t \t \t \t域: “全局” \t \t \t \t理由: “parseError” \t \t \t \t消息:“分析错误“ \t \t \t} - \t \t代码:400 \t \t消息:“Parse Error” \t} } –

+0

S Abraham:“||”在标题中也可能是一个问题。除了标题或描述中有“符号”之外,我已经上传到工作了。 – gulgi

+0

将它更改为小写字母“t”适用于我 –