Search code examples
c#youtubeyoutube-data-apigoogle-apis-explorer

Youtube API invalid search query invalidSearchFilter error


I am trying to access my private videos on through the YouTube API. I am currently getting a error when my app executes the request saying

"The request contains an invalid combination of search filters and/or restrictions. Note that you must set the type parameter to video if you set a value for the eventType, videoCaption, videoCategoryId, videoDefinition, videoDimension, videoDuration, videoEmbeddable, videoLicense, videoSyndicated, or videoType parameters."

I have set ForMine to be true and have set the Type property to be video, so I am not sure why it isn't working.

Request I'm sending to Youtube from fiddler:

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

And the code:

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();

Any help would be appreciated, thanks!


Solution

  • Either put the forMine: true and type: video without ChannelID or put the ChannelID and type: videowithout forMine.

    Hope it helps.