1

The question

My application needs to check if a specific comment, on a known video was successful sent by a user of the app.

To do this, I need to use the YouTube Data API (or perhaps so other method).

There seems to be two ways I can do this:

  1. I get all comments sent by the channel, and filter for the specific video.
  2. I get all comments from the specific video, and filter for the specific channel.

CommentThreads (list by channelId) CommentThreads (list by videoId)

However, "list by video" isn't ideal since if the video has a large amount of comments, it'd be hard to find the comments by the user / take longer.

To be clear, it's not a random user, the user will give the YouTube scopes required to find such information.

The Problem

When I use the samples with the API Explorer from the YouTube Data API reference page, it simply doesn't work.

Here's the error I get:

{
  "error": {
    "code": 400,
    "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 \u003ccode\u003ecommentThread\u003c/code\u003e resource in the request body to ensure that it is valid.",
    "errors": [
      {
        "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 \u003ccode\u003ecommentThread\u003c/code\u003e resource in the request body to ensure that it is valid.",
        "domain": "youtube.commentThread",
        "reason": "processingFailure",
        "location": "body",
        "locationType": "other"
      }
    ]
  }
} 

To be clear: I'm using the pre-made samples provided by Google themselves.

1st screenshot of "code" 2nd screenshot of "code"

So, how would I fix this and make CommentThreads (list by channelId) work?

Similar Questions

Get list of all comments made by a given user with Youtube Data API? - This question isn't exactly answered, and since it seems they don't want to request the user's consent the comments say that it's against YouTube policy and don't really mention the YouTube Data API. But most importantly, does not mention CommentThreads (channelId). For this reason, mainly the difference in consent, I don't think my question is a duplicate.

How to get comments posted by a specific account (channel) through YouTube Data API? - This question is much closer to mine, and even mentions CommentThreads, but they ignored the obvious "list by channelId" (unless it was implemented into the API after the question was asked), regardless there was no answer to my question.

  • please edit your question and include [example] i would like to test your code. – Linda Lawton - DaImTo Jan 27 '23 at 14:16
  • 1
    @LindaLawton-DaImTo | There's no code example, but I'll be more specific on how to reproduce by editing the question. – ChargedParticle Jan 27 '23 at 14:20
  • 1
    Alright, I've added screenshots to show everything I'm down to produce the error. – ChargedParticle Jan 27 '23 at 14:22
  • 1
    @ChargedParticle that looks like an error from the API - report the issue here on [Issue Tracker](https://issuetracker.google.com/issues?q=status:open%20componentid:186600&s=created_time:desc) as well. Also, I might be wrong, but, the documentation is *kind of* confusing about the use of this endpoint. As fas as I know, you cannot get the comments made by a channel using the API, but, rather, with google takeout export of the user's history. You *might* though, get the comments made by the user, but, you need the videos_ids from search comments on those videos. – Marco Aurelio Fernandez Reyes Jan 27 '23 at 14:49
  • If you trigger your application, verifying that the comment has made its way through, after having tried to send the comment, then thanks to `time` [`order`](https://developers.google.com/youtube/v3/docs/commentThreads/list#order) of [YouTube Data API v3](https://developers.google.com/youtube/v3) [CommentThreads: list](https://developers.google.com/youtube/v3/docs/commentThreads/list) endpoint, you won't have to do many requests as not many comments can be posted since your very recent trigger. – Benjamin Loison Jan 27 '23 at 15:10
  • As far as I know retrieving comments of **an arbitrary user** (maybe except if he consents and gives you some access as you talked about) isn't possible for privacy reasons. That's what is discussed in [Get list of all comments made by a given user with Youtube Data API?](https://stackoverflow.com/q/72637204), so this question isn't related to your question in my opinion, as in yours you assume that the given user has consented and given you some access. – Benjamin Loison Jan 27 '23 at 15:13
  • 1
    @MarcoAurelioFernandezReyes Thanks, I'll report the issue. As for the second part, the docs make it very explicit that you can "find by channelId". And as I mentioned in the question, it's not "a random user" but rather a user that has provided the application access to gain such info through scopes. – ChargedParticle Jan 27 '23 at 15:23
  • 1
    @BenjaminLoison Thanks, updated the question to include the reasoning for why this is not a duplicate to the other question. – ChargedParticle Jan 27 '23 at 15:30
  • 1
    @BenjaminLoison "thanks to time order of YouTube Data API v3 CommentThreads: list endpoint" - Yes, but the issue is if I sort by videoId, the video could get hundreds of comments per second, where as if I sort by channelId, the user is unlikely to send more than 1 comment per minute. Which is much more reliable, and yes requiring less requests. Therefore, I want to use channelId but there seems to be an error when I do it - mentioned in question post. – ChargedParticle Jan 27 '23 at 15:34
  • Thanks to [`maxResults`](https://developers.google.com/youtube/v3/docs/commentThreads/list#maxResults) that is `100` for [YouTube Data API v3](https://developers.google.com/youtube/v3) [CommentThreads: list](https://developers.google.com/youtube/v3/docs/commentThreads/list) endpoint. You can retrieve a hundred of comments per request, so even with hundreds of comments added within a second, you can retrieve as many comments in a few requests. – Benjamin Loison Jan 27 '23 at 15:46
  • @BenjaminLoison Yeah, although that would indeed work, it really would not be ideal. That's the Plan B. Still looking for Plan A suggestions. – ChargedParticle Jan 27 '23 at 16:46

1 Answers1

1

Thanks to the suggest made by @Marco Aurelio Fernandez Reyes, I looked at the IssueTracker and found that an issue that explained that this is an intended feature.

"CommentThreads (find by channelId)" is no longer supported and hasn't been for several months now.

Source material

Tigerrrrr
  • 526
  • 6
  • 24