2017-02-12 62 views
1

我試圖通過YouTube API訪問我的私人視頻。 我的應用執行請求時出現錯誤Youtube API無效搜索查詢invalidSearchFilter錯誤

「請求包含無效的搜索過濾條件和/或限制條件組合請注意,如果您設置的值爲eventType,videoCaption,videoCategoryId,videoDefinition,videoDimension,videoDuration,videoEmbeddable,videoLicense,videoSyndicated或videoType參數。「

我已將ForMine設置爲true,並將Type屬性設置爲視頻,因此我不確定它爲什麼不起作用。

請求我從小提琴手發送到YouTube:

GET /youtube/v3/search?part=snippet&channelId=XXXXXX&forMine=True&maxResults=1&order=date&type=video HTTP/1.1 
User-Agent: Youtube Sample google-api-dotnet-client/1.21.0.0 (gzip) 
Authorization: XXXXX 
Host: www.googleapis.com 
Accept-Encoding: gzip, deflate 
Connection: Keep-Alive 

,代碼:

string[] scopes = 
     { 
      YouTubeService.Scope.YoutubeReadonly 
     }; 


     try 
     { 
      var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret } 
                         , scopes 
                         , "user" 
                         , CancellationToken.None 
                         , new FileDataStore("Youtube.Auth.Store")).Result; 

      var youtubeService = new YouTubeService(new BaseClientService.Initializer 
      { 
       HttpClientInitializer = credential, 
       ApplicationName = "Youtube Sample" 
      }); 

      var searchListRequest = youtubeService.Search.List("snippet"); 
      searchListRequest.MaxResults = 1; 
      searchListRequest.Type = "video"; 
      searchListRequest.ForMine = true; 
      searchListRequest.Order = SearchResource.ListRequest.OrderEnum.Date; 
      searchListRequest.ChannelId = "XXXXX"; 

      var searchListResponse = searchListRequest.Execute(); 

任何幫助,將不勝感激,謝謝!

回答

0

要麼把forMine: truetype: video沒有ChannelID或將ChannelIDtype: video沒有forMine

希望它有幫助。

+0

非常感謝,這個固定了! – Jen