Hi, thanks for the quick reply...

I am uploading the Media Bundle already, just haven't posted that part of
the code. Here is the complete code, uploading the Media Bundle and than
trying to create the ad. What am I missing, please?

I've put a comment on where I'm stuck

try:
media_file_operation = self.g_ads_client.get_type(
'MediaFileOperation', version='v3')
media_file = media_file_operation.create
media_file.name.value = 'Ad Media Bundle'
media_file.type = (
self.g_ads_client.get_type(
'MediaTypeEnum',
version='v3'
).MEDIA_BUNDLE
)

# Download the ZIP as bytes from the URL
media_file.media_bundle.data.value = requests.get(bundle).content

media_file_service = self.g_ads_client.get_service(
'MediaFileService', version='v3')

mutate_media_files_response = (
media_file_service.mutate_media_files(
customer_id,
[media_file_operation]
)
)

ad_group_ad_service = self.g_ads_client.get_service('AdGroupAdService',
version='v3')
ad_group_service = self.g_ads_client.get_service('AdGroupService', version=
'v3')

uploads = []
ad_group_ad_operations = []
messages = []

for resource in mutate_media_files_response.results:
messages.append(
f'Uploaded file with resource name "{resource.resource_name}"'
)
uploads.append(resource.resource_name)

# Create ad group ad.
ad_group_ad_operation = self.g_ads_client.get_type('AdGroupAdOperation',
version='v3')
ad_group_ad = ad_group_ad_operation.create
ad_group_ad.ad_group.value = ad_group_service.ad_group_path(
customer_id, ad_group_id)
ad_group_ad.status = self.g_ads_client.get_type('AdGroupAdStatusEnum',
version='v3').PAUSED
# Set expanded display upload ad info
ad_group_ad.ad.display_upload_ad.display_upload_product_type = (
self.g_ads_client.get_type(
'DisplayUploadProductTypeEnum',
version='v3'
).HTML5_UPLOAD_AD
)

media_bundle_asset = AdMediaBundleAsset()
media_bundle_asset.asset.value = mutate_media_files_response.results[0
].resource_name
# here the problem.
ad_group_ad.ad.display_upload_ad.media_bundle = (media_bundle_asset)


Response error: AttributeError: Assignment not allowed to field
\"media_bundle\" in protocol message object.


*Fabio Szostak*
+55-41-98831-8311

f s


Em ter., 12 de mai. de 2020 às 11:33, Google Ads API Forum Advisor Prod <
adsapiforumadvi...@gmail.com> escreveu:

> Hi Fabio,
>
> Thank you for reaching out. You should start by creating a
> MediaBundleAsset
> <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v3.common#google.ads.googleads.v3.common.MediaBundleAsset>
> by following the instructions here
> <https://developers.google.com/google-ads/api/docs/assets/working-with-assets#python>
>  (but
> with type MediaBundleAsset). Once that is done and you have the asset ID,
> you can use the AdGroupAdService
> <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v3.services#adgroupadservice>
> to create a DisplayUploadAd
> <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v3.common?hl=sv#displayuploadadinfo>
>  and
> specify the media_bundle
> <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v3.common?hl=sv#google.ads.googleads.v3.common.AdMediaBundleAsset>
> attribute as the asset you created.
>
> Regards,
> Mitchell
> Google Ads API Team
>
> ref:_00D1U1174p._5004Q1zLTbr:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/CABN_4d%2BeUD3GThsCh5AB0NY5VOgGeO_8tSet2fn0ggRsH45kiA%40mail.gmail.com.

Reply via email to