Youtube video Asset creation: AttributeError: Assignment not allowed to field "youtube_video_id" in protocol message object.

638 views
Skip to first unread message

Stefan Delic

unread,
Jun 22, 2020, 6:49:40 AM6/22/20
to AdWords API and Google Ads API Forum

Hello, I am trying to create a video Asset using the Google Ads API Beta python library. I am getting this error:  "AttributeError: Assignment not allowed to field "youtube_video_id" in protocol message object" (I posted the code bellow).

The video was successfully uploaded to Youtube previously and I got the 11 character Youtube id that is required.

I was using this documentation as reference: https://developers.google.com/google-ads/api/reference/rpc/v3/Asset

I use the same workflow for creating image and text assets and it works just fine, but not for Youtube videos. I used these examples as reference: https://github.com/googleads/google-ads-python/tree/master/examples

Am I doing something wrong or is creating video/youtube assets via Google Ads API not allowed? 

google_ads_client = GoogleAdsClient.load_from_dict({"my_credentials": "my_credentials"})

operation = google_ads_client.get_type('AssetOperation', 'v3')

video_asset = operation.create
video_asset.type = google_ads_client.get_type('AssetTypeEnum', 'v3').YOUTUBE_VIDEO

# I get the error on this line when I try to assign my Youtube ID string
video_asset.youtube_video_asset.youtube_video_id = "tDUOo93p9mk"

asset_service = google_ads_client.get_service('AssetService', 'v3')

response = asset_service.mutate_assets(self.account_id, [operation])

Google Ads API Forum Advisor Prod

unread,
Jun 22, 2020, 11:17:21 AM6/22/20
to adwor...@googlegroups.com
Hi Stefan,

Thank you for reaching out. Please try making the following change to your code:

Instead of:
video_asset.youtube_video_asset.youtube_video_id = "tDUOo93p9mk"

Please try:
video_asset.youtube_video_asset.youtube_video_id.value = "tDUOo93p9mk"

Let me know if you are still facing any issues.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5004Q218KAa:ref

Stefan Delic

unread,
Jun 23, 2020, 5:27:40 AM6/23/20
to AdWords API and Google Ads API Forum
Hi Mitchell,

Thank you, that worked, it was an error on my part!

Best regards,
Stefan
Reply all
Reply to author
Forward
0 new messages