Hi, Thanks for the followup,
So once again I want to create and upload a completely new image ad inside an existing ad group/campaign using an image url. So I will post the error logs in two sections below. So the first log, is when I use the 'data' attribute as below: $ adGroupAd = new AdGroupAd ([ 'ad' => new Ad ([ 'name' => $ name, 'final_urls' => $ urls, 'image_ad' => new ImageAdInfo ([ 'mime_type' => MimeType :: IMAGE_PNG, 'pixel_width' => 200, 'pixel_height' => 200, 'image_url' => $pngImageUrl, 'preview_pixel_width' => 200, 'preview_pixel_height' => 200, 'preview_image_url' => $pngImageUrl, 'name' => $ imageName, 'data' => file_get_contents ($pngImageUrl), ]) ]), 'ad_group' => ResourceNames :: forAdGroup ($ this-> customerId, $ adGroupId), 'status' => AdGroupAdStatus :: PAUSED ]); The error log is then as follows: [2021-11-26 15:15:20] laravel.ERROR: { "message": "Request contains an invalid argument.", "Code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": 0, "data": " type.googleapis.com // <http://type.googleapis.com/> google. ads.googleads.v8.errors. GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode" : { "adError": "EMPTY_FIELD" }, "message": "A required field was not specified or is an empty string.", "trigger": { "stringValue": "" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "ad" }, { "fieldName": "display_url" } ] } } ] }, { "@type": 0, "data": "dL89I3epo9eHKHelHqeSsQ" } ] } {"userId": 505, "exception": "[ object] (Google \ \ ApiCore \\ ApiException (code: 3): { \ "message \": \ "Request contains an invalid argument. \", \ "Code \": 3, \ "status \": \ "INVALID_ARGUMENT \", \ "details \":[ { \ "@ type \": 0, \ "data \": \ " type.googleapis.com\\ / google.ads.googleads.v8. errors.GoogleAdsFailure \ " }, { \" @ type \ ": 0, \" data \ ": [ { \" errorCode \ ": { \" adError \ ": \" EMPTY_FIELD \ " }, \" message \ " : \ "A required field was not specified or is an empty string. \", \ "Trigger \": { \ "stringValue \": \ "\" }, \ "location \": { \ "fieldPathElements \": \ "fieldName \": \ "operations \", \ "index \": 0 }, { \ "fieldName \": \ "create \" }, { \ "fieldName \": \ "ad \" }, { \ "fieldName \": \ "display_url \" } ] } } ] }, { \ "@ type \": 0, \ "data \": \ "dL89I3epo9eHKHelHqeSsQ \" } ] } _________________________________________________________________________ Comment: I notice the fieldname 'display_url'. This does not seem to be included in the documentation for ImageAdInfo. Am I missing something here? ______________________________ ______________________________ ____________ Secondly, I tried the 'media_file' attribute instead of 'data' in the ImageAdInfo constructor as below: 'media_file' => new MediaFile ([ 'source_url' => $pngImageUrl , 'name' => 'testname' , 'type' => MediaType :: IMAGE, ]), There was an issue retrieving the full log, but below is the end of the stack trace (modified some local paths): [2021-11-26 15:23:28] laravel.ERROR: Expect string. {"userId": 505, "exception": "[ object] (InvalidArgumentException ( code: 0): Expect string. at localpath \\ google \\ protobuf \\ src \\ Google \\ Protobuf \\ Internal \\ GPBUtil. php: 96) [stacktrace] # 0 localpath \\ googleads \\ google- ads-php \\ src \\ Google \\ Ads \\ GoogleAds \\ V8 \\ Common \\ ImageAdInfo.php (411): Google \\ Protobuf \\ Internal \\ GPBUtil :: checkString (Object ( Google \\ Ads \\ GoogleAds \\ V8 \\ Resources \\ MediaFile), true) # 1 localpath \\ google \\ protobuf \\ src \\ Google \\ Protobuf \\ Internal \\ Message .php (1081): Google \\ Ads \\ GoogleAds \\ V8 \\ Common \\ ImageAdInfo-> setMediaFile (Object (Google \\ Ads \\ GoogleAds \\ V8 \\ Resources \ \ MediaFile)) # 2 localpath \ \ google \\ protobuf \\ src \\ Google \\ Protobuf \\ Internal \\ Message.php (80): Google \\ Protobuf \\ Internal \\ Message-> mergeFromArray (Array) # 3 localpath \\ googleads \\ google-ads-php \\ src \\ Google \\ Ads \\ GoogleAds \\ V8 \\ Common \\ ImageAdInfo.php (103): Google \\ Protobuf \\ Internal \\ Message -> __ construct (Array) # 4 pathtodriver \ \ GoogleAdsDriver. php (x): Google \\ Ads \\ GoogleAds \\ V8 \\ Common \\ ImageAdInfo -> __ construct (Array) # 5 pathtodriver \\ GoogleAdsDriver. php (x): pathtodriver \\ GoogleAdsDriver- > createImageAd () ______________________________________________________ Note: I notice a failure in this method in ImageAdInfo.php: public function setMediaFile($var) { GPBUtil::checkString($var, True); $this->writeOneof(12, $var); return $this; } It fails here: GPBUtil::checkString($var, True); I notice the $var passed in is the MediaFile object (not a string). Why is it expecting a string? Let me know if you have any more questions! Kind regards, R torsdag 25 november 2021 kl. 04:02:08 UTC+1 skrev adsapi: > Hi R, > > Thank you for reaching out to our API support team. > > As per the data > <https://developers.google.com/google-ads/api/reference/rpc/v9/ImageAdInfo#data> > attribute > documentation, the information to be passed should be "*Raw image data as > bytes.*". That said, and as we are not familiar with all the available > methods from the client libraries, could you provide more details on what > the *file_get_contents()* outputs? > > Also, so our team can take a closer look at the cause, could you provide > as well the complete request > <https://developers.google.com/google-ads/api/docs/concepts/field-service#request> > > and response > <https://developers.google.com/google-ads/api/docs/concepts/field-service#response> > > logs, with the request-id > <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>, > > generated when the error occurred? > > If you haven't yet, you can enable logging by referring to this PHP > client library guide > <https://developers.google.com/google-ads/api/docs/client-libs/php/logging?hl=en>. > You > may then send the requested information via the *Reply privately to > author* option. If this option is not available, you may send the details > directly to our googleadsa...@google.com alias instead. > > Best regards, > > Reminder: Share your feedback about the Google Ads (AdWords) API! Take the > 2021 > Google Ads API and AdWords API Annual Survey > <https://google.qualtrics.com/jfe/form/SV_eQbOpf4VxRyyqqO?source=so> > > [image: Google Logo] > Peter Laurence Napa Oliquino > Google Ads API Team > > > ref:_00D1U1174p._5004Q2RvvI1: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/a9ef2645-8696-4eac-86cb-d9bb50bd42dfn%40googlegroups.com.