【问题标题】:Error using youtube API V3 for C#使用 C# 的 youtube API V3 时出错
【发布时间】:2013-08-08 10:16:04
【问题描述】:

我一直在我的应用程序中使用 youtube API V3。我已引用此 link 来检索与关键字关联的搜索结果。

    public static void Search(string keyword, ref List<string> videoList)
    {
        // Validate keyword
        if (string.IsNullOrWhiteSpace(keyword))
        {
            return;
        }
        // Create a youtube service
        YoutubeService youtube = new YoutubeService(new BaseClientService.Initializer()
        {
            ApiKey = GoogleCredentials.apiKey
        });

        SearchResource.ListRequest listRequest = youtube.Search.List("snippet");
        listRequest.Q = keyword;
        listRequest.Order = SearchResource.Order.Rating;

        // Fetch the response from youtube
        SearchListResponse searchResponse = listRequest.Fetch();


        foreach (SearchResult searchResult in searchResponse.Items)
        {
            videoList.Add(searchResult.Id.VideoId);
        }
    }

在这行代码中

        SearchListResponse searchResponse = listRequest.Fetch();

它会引发以下错误。

Google.Apis.dll 中出现“Google.GoogleApiRequestException”类型的未处理异常 附加信息:Google.Apis.Requests.RequestError

  Bad Request [400]

可能是什么问题?

【问题讨论】:

    标签: c# youtube-api google-api youtube.net-api


    【解决方案1】:

    我犯了一个愚蠢的错误。我没有使用 API 密钥,而是使用了客户端密码。更换后问题解决。

    【讨论】:

      猜你喜欢
      • 2015-01-01
      • 2021-12-16
      • 2018-08-24
      • 2019-07-08
      • 1970-01-01
      • 2018-06-28
      • 1970-01-01
      • 1970-01-01
      • 2016-11-13
      相关资源
      最近更新 更多