我正在编写一些函数Youtube API version 3
。我在用python
但在谷歌提供的测试控制台中确认了我的错误。
(我正在提出所有授权请求,只是没有在下面粘贴我的密钥)
Python 客户端库自动添加forMine
参数给我的Search().list()
请求,尽管我可以将其设置为 false。我无法从我的请求中删除该参数,如果我省略该参数,它默认为 true。如果我将其设置为 false,则会收到此错误:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/youtube/v3/search?forMine=false&maxResults=50&q=week&part=snippet&alt=json&type=playlist&order=date returned "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 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.">
API Explorer 上的症状:
请求失败(forMine
参数已删除):
GET https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=false&q=week&type=playlist&key={YOUR_API_KEY}
不会失败的请求(forMine
参数设置为 false):
GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=week&type=playlist&key={YOUR_API_KEY}
我的 python 代码失败了,我认为应该可以工作:
result = youtube_service.search().list(part='snippet', forMine=False, q='test', type='playlist', maxResults=50).execute()
任何人都可以验证这是我的错误还是 API 错误吗?