Issue with Creating camp Display Upload Ad in Google Ads API v14 - python

31 views
Skip to first unread message

Antony Kiên

unread,
May 30, 2024, 4:48:38 AM5/30/24
to Google Ads API and AdWords API Forum
I'm trying to create an display upload ad in Google Ads API v14, but I'm encountering issues. Specifically, I'm getting an "INVALID_ARGUMENT" error with the message "Mutates are not allowed for the requested resource."

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
    # 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}'."
    )

Error Message: Request with ID "xKDxTq8R83Lu7ElSsLBwYw" failed with status "INVALID_ARGUMENT" and includes the following errors: Error with message "Mutates are not allowed for the requested resource.". On field: operations On field: create On field: ad

file was uploaded and returned the path Uploaded file with resource name 'customers/12344/assets/12234' and I entered it in the function's ad_asset_resource_name
i try to v14

Despite these checks, I'm still encountering the same error. Any insights or suggestions on what might be going wrong would be greatly appreciated.

Google Ads API Forum Advisor

unread,
May 30, 2024, 11:01:30 AM5/30/24
to kiez...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

I understand that you've encountered the error "MUTATE_NOT_ALLOWED " when trying to create a display upload ad. Could you please confirm if the recommended format / specifications for the HTML_5_UPLOAD_AD's media_bundle, discussed here, was applied prior to using it for creating the said ad?

I could see that you are using the 'v14'  which is deprecated and about sunset on the 5 June 2024. After this date, all v14 API requests will begin to fail. I would recommend migrating to the latest version v16 and you may follow this link to Upgrade to the latest version.

Please note that provided sample code is not sufficient to investigate the issue further. To replicate the issue from our end, provide us with the complete API logs (request and response with request-id and request header) generated at your end.

Since you are using a Python client library, I would request you to enable logging for the Python client library that you are using. You can refer to the guide Python to enable logging at your end. 

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02tJ8RQ:ref" (ADR-00237148)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages