Uses below script
def _create_display_upload_ad_group_ad(
client, customer_id, ad_group_id, ad_asset_resource_name
):
"""Creates a new HTML5 display upload ad and adds it to the given ad
group.
Args:
client: An initialized Google Ads client.
customer_id: The Google Ads customer ID.
ad_group_id: The ID of the ad group to which the new ad will be
added.
ad_asset_resource_name: The resource name of the media bundle
containing
the HTML5 components.
"""
# Get the AdGroupAdService client.
ad_group_ad_service = client.get_service("AdGroupAdService")
# Create an AdGroupAdOperation.
ad_group_ad_operation = client.get_type("AdGroupAdOperation")
# Configure the ad group ad fields.
ad_group_ad = ad_group_ad_operation.create
ad_group_ad.status = client.enums.AdGroupAdStatusEnum.PAUSED
ad_group_ad.ad_group =
client.get_service("AdGroupService").ad_group_path(
customer_id, ad_group_id
)
# Configured the ad as a display upload ad.
display_upload_ad = ad_group_ad.ad
display_upload_ad.name = "Ad for HTML5"
display_upload_ad.final_urls.append("http://example.com/html5")
# Exactly one of the ad_data "oneof" fields must be included to specify
the
# ad type. See:
https://developers.google.com/google-ads/api/reference/rpc/latest/Ad for
# the full list of available types. By setting a "display_upload_ad"
# subfield it sets that as the "oneof" field for the Ad.
display_upload_ad.display_upload_ad.media_bundle.asset = (
ad_asset_resource_name
)
display_upload_ad.display_upload_ad.display_upload_product_type = (
client.enums.DisplayUploadProductTypeEnum.HTML5_UPLOAD_AD
)
# Add the ad group ad to the client account and display the resulting
# ad's resource name.
mutate_ad_group_ads_response = ad_group_ad_service.mutate_ad_group_ads(
customer_id=customer_id, operations=[ad_group_ad_operation]
)
print(
"Created new ad group ad with resource name "
f"'{mutate_ad_group_ads_response.results[0].resource_name}'."
)
When I run the script I get error like :
Request made: ClientCustomerId: 1467150772, Host: googleads.googleapis.com,
Method: /google.ads.googleads.v8.services.GoogleAdsService/Mutate,
RequestId: 9C-sO_DDxQBYHci41zRuug, IsFault: True, FaultMessage: Mutates are
not allowed for the requested resource.
Failed to retry:
(<_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid
argument."
debug_error_string
= "{"created":"@1637125574.891875500","description":"Error received from
peer
ipv4:142.251.42.74:443","file":"src/core/lib/surface/call.cc","file_line":1069,"grpc_message":"Request
contains an invalid argument.","grpc_status":3}"
>,
<_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains
an invalid argument."
debug_error_string =
"{"created":"@1637125574.891875500","description":"Error received from peer
ipv4:142.251.42.74:443","file":"src/core/lib/surface/call.cc","file_line":1069,"grpc_message":"Request
contains an invalid argument.","grpc_status":3}"
>, errors {
error_code {
mutate_error: MUTATE_NOT_ALLOWED
}
message: "Mutates are not allowed for the requested resource."
location {
field_path_elements {
field_name: "mutate_operations"
index: 0
}
field_path_elements {
field_name: "ad_group_ad_operation"
}
field_path_elements {
field_name: "create"
}
field_path_elements {
field_name: "ad"
}
}
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/a2a12ef4-7fc4-42b8-a094-7e1b6af08518n%40googlegroups.com.
