我想訪問我對其他視頻的評論。但我不明白這個請求有什么問題。我把youtube.force-ssl范圍。
(Pdb) request = self.service.commentThreads().list(part="id,replies,snippet", channelId="UCxz_B5DVTdZV5c0JLctjqUA")
INFO __init__.py line:49 2022-09-19 21:23:55,044 - file_cache is only supported with oauth2client<4.0.0
(Pdb) request.execute()
*** googleapiclient.errors.HttpError: <HttpError 400 when requesting https://youtube.googleapis.com/youtube/v3/commentThreads?part=id,replies,snippet&channelId=UCxz_B5DVTdZV5c0JLctjqUA&alt=json returned "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. Check the structure of the <code>commentThread</code> resource in the request body to ensure that it is valid.". Details: "[{'message': "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. Check the structure of the <code>commentThread</code> resource in the request body to ensure that it is valid.", 'domain': 'youtube.commentThread', 'reason': 'processingFailure', 'location': 'body', 'locationType': 'other'}]">
(Pdb) request.headers
{'accept': 'application/json', 'accept-encoding': 'gzip, deflate', 'user-agent': '(gzip)', 'x-goog-api-client': 'gdcl/2.52.0 gl-python/3.8.10', 'content-length': '0'}
(Pdb) request.uri
'https://youtube.googleapis.com/youtube/v3/commentThreads?part=id,replies,snippet&channelId=UCxz_B5DVTdZV5c0JLctjqUA&alt=json'
(Pdb) request.body
(Pdb) request.to_json()
'{"uri": "https://youtube.googleapis.com/youtube/v3/commentThreads?part=id,replies,snippet&channelId=UCxz_B5DVTdZV5c0JLctjqUA&alt=json", "method": "GET", "body": null, "headers": {"accept": "application/json", "accept-encoding": "gzip, deflate", "user-agent": "(gzip)", "x-goog-api-client": "gdcl/2.52.0 gl-python/3.8.10", "content-length": "0"}, "methodId": "youtube.commentThreads.list", "resumable": null, "response_callbacks": [], "_in_error_state": false, "body_size": 0, "resumable_uri": null, "resumable_progress": 0}'
(Pdb) request.body
另一方面,下面的行回傳有效的 200 回應。
(Pdb) request=self.service.commentThreads().list(part="id,replies,snippet", allThreadsRelatedToChannelId="UCxz_B5DVTdZV5c0JLctjqUA")
INFO __init__.py line:49 2022-09-19 22:06:17,504 - file_cache is only supported with oauth2client<4.0.0
(Pdb) request.execute()
我已啟用 Youtube Data API 并youtube.force-ssl在 Google Cloud 控制臺上再次提供范圍,但我不確定我是否必須提供任何其他權限。根據檔案。channelId應該是一個有效的引數,但我不明白為什么如果我給了 channelId 它會回傳 400 錯誤。
最奇怪的是,即使是
但是,如果我給我的頻道 ID 提供allThreadsRelatedToChannelId引數,它會按預期回傳 HTTP 200 回應。

uj5u.com熱心網友回復:
他們洗掉了channelId引數:( https://issuetracker.google.com/issues/247966553
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/510759.html
標籤:http谷歌APIyoutube-apiyoutube-数据-api谷歌开发者控制台
上一篇:POST請求成功但GET請求為空
