Required fields to add the new ImageAds (GoogleAdsAPI)

132 views
Skip to first unread message

高嶋葵

unread,
Dec 20, 2019, 6:13:48 AM12/20/19
to AdWords API and Google Ads API Forum
We tried to add new ImageAds using by the GoogleAds API Ver 2.2.0.

We used the below code :
```
$imageAdInfo = new ImageAdInfo([
'data' => new BytesValue(['value' => file_get_contents($file)]),
]);
$ad = new Ad([
'image_ad' => $imageAdInfo,
'final_urls' => [
new StringValue(['value' => 'http://www.example.com/cruise/space/']),
new StringValue(['value' => 'http://www.example.com/locations/mars/'])
],
]);
// Creates an ad group ad to hold the above ad.
$adGroupAd = new AdGroupAd([
'ad_group' => new StringValue(
['value' => AdGroupServiceClient::adGroupName($this->customerId, $adwordsAdgroupId)]
),
'status' => AdGroupAdStatus::PAUSED,
'ad' => $ad
]);
// Creates an ad group ad operation and add it to the operations array.
$adGroupAdOperation = new AdGroupAdOperation();
$adGroupAdOperation->setCreate($adGroupAd);

// Issues a mutate request to add the ad group ads.
$adGroupAdServiceClient = $this->googleAdsClient->getAdGroupAdServiceClient();
$response = $adGroupAdServiceClient->mutateAdGroupAds($this->customerId, [$adGroupAdOperation]);


However, we got the following error message from API:
```
  1. message"{↵ "message": "Request contains an invalid argument.",↵ "code": 3,↵ "status": "INVALID_ARGUMENT",↵ "details": [↵ {↵ "@type": "google.ads.googleads.v2.errors.googleadsfailure-bin",↵ "data": "<Unknown Binary Data>"↵ },↵ {↵ "@type": "grpc-status-details-bin",↵ "data": "<Unknown Binary Data>"↵ },↵ {↵ "@type": "request-id",↵ "data": "GbrTnlpsh0jE6v_LuBkDPw"↵ }↵ ]↵}"
  2. exception"Google\Ads\GoogleAds\Lib\V2\GoogleAdsException"
  3. file"/www/weddingpark.net/at-diamond-metal5/releases/20191202065757/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V2/GoogleAdsExceptionMiddleware.php"
```

So, we want to know the required fields to add the new ImageAd.
However, we couldn't find the information about this.

Could you please tell us the required fields in the above case?

Best Regards.

Google Ads API Forum Advisor Prod

unread,
Dec 20, 2019, 2:35:56 PM12/20/19
to taka...@weddingpark.co.jp, adwor...@googlegroups.com
Hi,

Thank you for reaching out. Can you please share the detailed (Debug message) request and response logs via reply privately to author so that I can further investigate the issue? You can find information on enabling logging here. The complete error message should notify you which argument is causing the error.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UOEypZ:ref
Reply all
Reply to author
Forward
0 new messages