gpt4 book ai didi

java - YouTube错误400缺少Prams API V3

转载 作者:行者123 更新时间:2023-12-03 06:22:00 24 4
gpt4 key购买 nike

我发送以下请求,我得到error 400 missing params,但是当我通过GET手动发送请求时,它工作正常:

try {
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest arg0) throws IOException {}
}).setApplicationName("youtube-cmdline-myuploads-sample").build();

YouTube.Channels.List channelRequest = youtube.channels().list("id,snippet");
channelRequest.setKey("key");
//channelRequest.setFields("items/contentDetails,nextPageToken,pageInfo");
channelRequest.set("channelId", "UC-9-kyTW8ZkZNDHQJ6FgpwQ");
System.out.println(channelRequest.toString());
ChannelListResponse channelResult = channelRequest.execute(); //error here
List<Channel> channelsList = channelResult.getItems();
...

但是由于某些原因,它可行:
https://www.googleapis.com/youtube/v3/search?key=key&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&part=snippet,id&order=date&maxResults=20

更详细的错误:
    {
"code" : 400,
"errors" : [ {
"domain" : "youtube.parameter",
"location" : "",
"locationType" : "parameter",
"message" : "No filter selected.",
"reason" : "missingRequiredParameter"
} ],
"message" : "No filter selected."
}

最佳答案

您使用的是错误的类(class)。它不是 channel ,而是根据您提到的有效网址的搜索列表。

YouTube.Search.List searchRequest = youtube.search().list("id,snippet");

关于java - YouTube错误400缺少Prams API V3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33307352/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com