Home > Back-end >  HttpError 400 when requesting on Youtube commentThreads: Check the structure of the <code>comm
HttpError 400 when requesting on Youtube commentThreads: Check the structure of the <code>comm

Time:09-22

I am tying to access my comments on other videos. But I didn't understand that what is wrong with the request. I put youtube.force-ssl scope.

(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

On the other hand lines below return a valid 200 response.

(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()

I have enabled Youtube Data API and give youtube.force-ssl scope again on Google Cloud console but I am not sure that am I have to give any other permissions. According to the doc. channelId should be a valid argument but I didn't understand why it returns 400 error if I gave channelId.

Weirdest thing is that even the same example on enter image description here

However if I give my channel's id with allThreadsRelatedToChannelId argument it returns a HTTP 200 responseas expected.

enter image description here

CodePudding user response:

They had removed channelId parameter :( https://issuetracker.google.com/issues/247966553

  • Related