Creating an ad_group_ad.image_ad using a media_file

68 views
Skip to first unread message

Adam Walters

unread,
Mar 10, 2023, 7:13:11 PM3/10/23
to Google Ads API and AdWords API Forum
I have successfully created a MediaFile within the account and am trying to use that to create a Display ad (non-HTML5), but when running this function I receive the below error:

    def create_display_upload_ad_group_ads(self, ad_group_id, customer_id):

        ad_group_ad_operation = client.get_type("AdGroupAdOperation")
        ad_group_ad_service = client.get_service("AdGroupAdService")
        # Configure the ad group ad fields.
        ad_group_ad = ad_group_ad_operation.create
        ad_group_ad.status = client.enums.AdGroupAdStatusEnum.ENABLED
        ad_group_ad.ad_group = client.get_service("AdGroupService").ad_group_path(
            self.customer_id, self.ad_group_id
        )

        # Configured the ad as a display ad.
        display_ad = ad_group_ad.ad
        display_ad.name = 'Ad Name'
        display_ad.final_urls.append(self.landing_page)
        display_ad.display_url = 'digible.com'
        display_ad.image_ad.media_file = "customers/3727734182/mediaFiles/156598151473"

        ad_group_ad_service.mutate_ad_group_ads(
            customer_id=customer_id, operations=[ad_group_ad_operation]
        )

ERROR Recieved:
Request with ID "5baQ0V9cGCiQ5jFaPaRfyg" failed with status "INVALID_ARGUMENT" and includes the following errors:
Error with message "The image is not of legal dimensions.".
On field: operations
On field: create
On field: ad
On field: image_ad
On field: media_file

Google Ads API Forum Advisor

unread,
Mar 13, 2023, 7:56:00 AM3/13/23
to ad...@digible.com, adwor...@googlegroups.com

Hi Adam,


Thanks for reaching out to the Google Ads API team. I hope you are doing well today.


With regards to your concern, to further check this issue, could you provide the complete request and response logs with request ID and request header generated on your end?  If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link, so that we can further check and provide precise guidance accordingly.


You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.
 

Regards,

Google Logo Google Ads API Team



ref:_00D1U1174p._5004Q2jYIhK:ref

Adam Walters

unread,
Mar 13, 2023, 5:35:28 PM3/13/23
to Google Ads API and AdWords API Forum
Yes. Please see below:
Method: /google.ads.googleads.v13.services.AdGroupAdService/MutateAdGroupAds
Host: googleads.googleapis.com
Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": "2151671644",
  "x-goog-api-client": "gl-python/3.9.4 grpc/1.51.3 gax/2.11.0 gccl/20.0.0 pb/4.21.11",
  "x-goog-request-params": "customer_id=3727734182"
}
Request: customer_id: "3727734182"
operations {
  create {
    status: ENABLED
    ad_group: "customers/3727734182/adGroups/145390685654"
    ad {
      final_urls: "https://www.digible.com"
      display_url: "digible.com"
      name: "Ad Name"
      image_ad {
        media_file: "customers/3727734182/mediaFiles/156598151473"
      }
    }
  }
}


Response
-------
Headers: {
  "google.ads.googleads.v13.errors.googleadsfailure-bin": "\nh\n\u0003\u0002\u0005\u0012%The image is not of legal dimensions.\":\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\u0004\n\u0002ad\u0012\n\n\bimage_ad\u0012\f\n\nmedia_file\u0012\u0016nwA_KBVxSEh-dPH6OP-L0g",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nDtype.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure\u0012\u0001\nh\n\u0003\u0002\u0005\u0012%The image is not of legal dimensions.\":\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006create\u0012\u0004\n\u0002ad\u0012\n\n\bimage_ad\u0012\f\n\nmedia_file\u0012\u0016nwA_KBVxSEh-dPH6OP-L0g",
  "request-id": "nwA_KBVxSEh-dPH6OP-L0g"
}
Fault: errors {
  error_code {
    image_error: UNEXPECTED_SIZE

  }
  message: "The image is not of legal dimensions."
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "ad"
    }
    field_path_elements {
      field_name: "image_ad"
    }
    field_path_elements {
      field_name: "media_file"
    }
  }
}
request_id: "nwA_KBVxSEh-dPH6OP-L0g"

Adam Walters

unread,
Mar 13, 2023, 5:38:10 PM3/13/23
to Google Ads API and AdWords API Forum
Reply all
Reply to author
Forward
0 new messages