2013-10-02 68 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」適用於我 –