I need to get the ID and title for all videos from my own YouTube channel. Some of videos are unlisted, but I want to get them too. I use this version of the client library:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev222-1.25.0</version>
</dependency>
According to the documentation I use this Java code:
YouTube.Search.List request = youtubeService.search()
.list("id,snippet");
SearchListResponse response = request.setChannelId(channelId)
.setForMine(true)
.setMaxResults(50L)
.setType("video")
.execute();
But got this exception:
400 Bad Request
GET https://www.googleapis.com/youtube/v3/search?channelId=channelId&forMine=true&maxResults=50&part=id,snippet&type=video
{
"code" : 400,
"errors" : [ {
"domain" : "youtube.search",
"location" : "parameters.",
"locationType" : "other",
"message" : "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.",
"reason" : "invalidSearchFilter"
} ],
"message" : "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters."
}
Moreover I got the same error using interactive tool on this page:
https://developers.google.com/youtube/v3/docs/search/list?apix=true
.
If I remove .setForMine(true)
it works fine, but doesn't give me unlisted videos (gives me only public videos).
Are there any possibilities to get the ID and title of all videos (unlisted included) from my own channel via the API?