0

I was wondering why is that that some channels return an array in the following code and other don't? I'm trying to make a video gallery but the specific channel won't return me that array that has contentDetails. I also have access to the youtube account if I need to change any settings in there to allow this code to work. I also already have api credentials and added API v3 to the project.

$(document).ready(function() {
    $.get("https://www.googleapis.com/youtube/v3/channels", {
            part: 'contentDetails',
            forUsername: channelName,
            key: 'myKeyvalue'},
            function(data) {
                console.log(data);
                //upload_id = data.items[0].contentDetails.relatedPlaylists.uploads;
            }
    )
}

Thanks in advance.

The data object should contain an array.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • Maybe you're confused between all different YouTube channel identifiers, see [this Stack Overflow answer](https://stackoverflow.com/a/73807243) for more details. If you don't solve your problem with this answer, then please share an example of `channelName` returning an empty array. – Benjamin Loison Mar 17 '23 at 14:48

1 Answers1

0

That behaviour might be due the channelName value is different from the common/public name.

Example:

If you want to check the channel Markiplier, for search this channel using the channels.list endpoint, you have to use the value markiplierGAME as value in the forUsername field.

So, as alternative you have to get the correct value for the forUsername field or, use the id - in this case, the channel_id.