首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google-api-java-client: setForMine(true)导致invalidSearchFilter错误

google-api-java-client: setForMine(true)导致invalidSearchFilter错误
EN

Stack Overflow用户
提问于 2015-04-15 23:51:33
回答 1查看 217关注 0票数 1

如果我打电话给

代码语言:javascript
复制
YouTube.Search.List.setForMine(true);

然后,即使在使用YouTube.Search.List.setForMine(true)时也需要调用YouTube.Search.List.setType("video"),我也会得到以下错误

代码语言:javascript
复制
There was a service error: 400 : Invalid combination of search filters and/or restrictions.
hu.pocketguide.kmlvideo.youtube.exception.YouTubeException: Service error.
    at com.google.api.services.samples.youtube.cmdline.data.PgFindByKmlId.findVideosByKmlId(PgFindByKmlId.java:107)
    at com.google.api.services.samples.youtube.cmdline.data.PgFindByKmlId.main(PgFindByKmlId.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "youtube.search",
    "location" : "",
    "locationType" : "parameter",
    "message" : "Invalid combination of search filters and/or restrictions.",
    "reason" : "invalidSearchFilter"
  } ],
  "message" : "Invalid combination of search filters and/or restrictions."
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1049)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
    at com.google.api.services.samples.youtube.cmdline.data.PgFindByKmlId.findVideosByKmlId(PgFindByKmlId.java:100)
    ... 7 more

在Try it!中同样的查询!部分的https://developers.google.com/youtube/v3/docs/search/list工作。

谁能告诉我如何使用google-api-java-client过滤标签(关键字)来列出我自己的“未列出的”视频?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-04-16 03:30:49

我找到问题了。我未能将适当的凭据对象传递给new YouTube.Builder(...)。通过以下初始化,它可以正常工作:

代码语言:javascript
复制
List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube.readonly");
Credential credential = Auth.authorize(scopes, "mycredentialdatastore");
            youtube = new YouTube.Builder(
                    Auth.HTTP_TRANSPORT,
                    Auth.JSON_FACTORY,
                    credential).setApplicationName("mysample").build();

尽管如此,我仍然发现错误消息具有误导性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29654974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档