Youtube API无效搜索查询invalidSearchFilter错误

时间:2017-02-12 07:45:58

标签: c# youtube youtube-data-api google-apis-explorer

我正在尝试通过YouTube API访问我的私人视频。 当我的应用执行请求

时,我当前收到错误

"请求包含搜索过滤器和/或限制的无效组合。请注意,如果为eventType,videoCaption,videoCategoryId,videoDefinition,videoDimension,videoDuration,videoEmbeddable,videoLicense,videoSyndicated或videoType参数设置了值,则必须将type参数设置为video。"

我已将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();

任何帮助将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:1)

forMine: truetype: video放在ChannelID之后,或将ChannelIDtype: video放在forMine之内。

希望它有所帮助。