Reputation: 469
I'm just trying to make a search over youtube for my own videos that publisher after X date
However when i use publishAfter
parameter, it's giving invalidSearchFilter
error even of i set type
parameter as video
.
Error description is like this:
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 either the forContentOwner
or forMine
parameters to true
. You must also 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.
You can reproduce this error from: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&publishedAfter=1970-01-01T00%253A00%253A00Z&type=video&_h=11& (after login via oauth 2.0)
Any idea what can i do in this situation?
Upvotes: 0
Views: 1314
Reputation: 4547
I am trying to work on a task to retrieve all the videos from our own channel, my problem with using forMine
filter was, I was passing channelId
filter alongside forMine
filter (which actually does not make sense, if I am saying to get my own data then I should not pass channel id explicitly, so I blame myself for that), which was returning as an error saying that Request contains an invalid argument.
Here is what my request was when it was causing the error:
curl --location -g --request GET 'https://youtube.googleapis.com/youtube/v3/search?part=snippet,id&channelId=[Channel ID]&forMine=true&order=date&type=video&key=[API KEY]&maxResults=25' \
--header 'Authorization: Bearer [ACCESS TOKEN]' \
--header 'Accept: application/json'
And this was the JSON return:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [
{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
As soon as I removed the channelId
query parameter, the error went away.
Upvotes: 0
Reputation: 17613
I used the link that you provided. The problem is not the date. The problem is the conflicting search restrictions that you used. To make your search work, leave the "forMine" parameter empty so it doesn't conflict with your date filters and possibly the 'q' parameter as well. Do that and it will work.
Also, you have to specify the channelID to specify it's yours. Give it a try
Upvotes: 2