Jack Marchetti
Jack Marchetti

Reputation: 15754

Set the channelSection country using the YouTube API

I have a YouTube channel. Within that channel I have a channelSection called "Brazil".

I want to limit that section so that only people in Brazil can view it.

In the documentation I see how to set the country parameter for a channel, but not a channelSection.

Per documentation: https://developers.google.com/youtube/v3/docs/channelSections/update

The only items I can update are:

Our YouTube rep wrote to us that "To set the snippet.country property for a channel resource, you actually need to update the brandingSettings.channel.country property. This setting does not affect targeting in any way."

So I am a bit confused. Do I set the channel's brandingSettings.channel.country setting to Brazil or the channelSection, and if so, how?

Update

Following the answer below, I receive the following error:

"domain": "global", "reason": "backendError", "message": "Backend Error" 

Upvotes: 1

Views: 841

Answers (1)

not_a_bot
not_a_bot

Reputation: 2372

I think they might've been confused about what you were trying to do. Changing the brandingSettings.channel property should only set

the country with which the channel is associated. [source]

I believe the correct way to do what you're asking is by adding "Brazil" to the targeting.regions[] list.

From the documentation:

targeting.countries[]: A list of ISO 3166-1 alpha-2 country codes where the channel section is visible. [source]

Since you've already created the channelSection, you'd just use channelSections.update() to provide a channelSection resource and specify Brazil for the targeting country. According to the ISO 3166-1 country code list, the code for Brazil is "BR". Note that if you are submitting an update request and your request does not specify a value for a property that already has a value, the property's existing value will be deleted.

Afterwards, you can use channelSections.list() to check your channelSection resource and see that it should only be visible to users in Brazil (targeting.countries[] should have "BR" as the only value). Or maybe you could use some proxy extension to view the channel section from different countries to see if it's working as expected.

Upvotes: 1

Related Questions