Throw “This operation is not permitted on this campaign type” when I create an AdGroupAd

78 views
Skip to first unread message

MCC智美

unread,
Aug 12, 2019, 5:47:42 AM8/12/19
to AdWords API and Google Ads API Forum
Hello,

When I call the Google Ads API(V2) to create an AdGroupAd, throw an error about “This operation is not permitted on this campaign type” .1565602956447.jpg

before this,I have set the Campaign advertising_channel_type=MULTI_CHANNEL,advertising_channel_sub_type=APP_CAMPAIGN,AdGroup type=UNSPECIFIED.


and here is my code about create AdGroupAd:

public static function runExample(
        GoogleAdsClient $googleAdsClient,
        $customerId,
        $adGroupId
    ) {
        $adGroupResourceName = new StringValue(['value' => ResourceNames::forAdGroup($customerId, $adGroupId)]);

        $asset_operations = [];
        $ad_operations = [];

        $asset = new Asset([
            'youtube_video_asset' => new YoutubeVideoAsset([
                'youtube_video_id' => new StringValue(['value' => 'adZeOuXpqIQ'])
            ]),
            'type' => AssetType::YOUTUBE_VIDEO,
        ]);
        $assetOperation = new AssetOperation();
        $assetOperation->setCreate($asset);
        $asset_operations[] = $assetOperation;

        $assetServiceClient = $googleAdsClient->getAssetServiceClient();
        $response = $assetServiceClient->mutateAssets($customerId,$asset_operations);
        foreach ($response->getResults() as $asset) {
            $assetResourceName = $asset->getResourceName();
        }

        $appAdInfo = new AppAdInfo([
            'youtube_videos'=>[
                new AdVideoAsset([
                    'asset'=>new StringValue(['value' => $assetResourceName]),
                ])
            ],
        ]);

        //Sets the expanded text ad info on an Ad.
        $ad = new Ad([
            'type'=>AdType::APP_AD,
            'app_ad'=>$appAdInfo,
        ]);

        // Creates an ad group ad to hold the above ad.
        $adGroupAd = new AdGroupAd([
            'ad_group' => $adGroupResourceName,
            'status' => AdGroupAdStatus::PAUSED,
            'ad'=>$ad,
        ]);

        // Creates an ad group ad operation and add it to the operations array.
        $adGroupAdOperation = new AdGroupAdOperation();
        $adGroupAdOperation->setCreate($adGroupAd);
        $ad_operations[] = $adGroupAdOperation;

        // Issues a mutate request to add the ad group ads.
        $adGroupAdServiceClient = $googleAdsClient->getAdGroupAdServiceClient();
        $response = $adGroupAdServiceClient->mutateAdGroupAds($customerId, $ad_operations);
        foreach ($response->getResults() as $addedAdGroupAd) {
            /** @var AdGroupAd $addedAdGroupAd */
            printf(
                "Expanded text ad was created with resource name: '%s'%s",
                $addedAdGroupAd->getResourceName(),
                PHP_EOL
            );
        }
    }

}



How to solve this problem? 

Thank you

Google Ads API Forum Advisor Prod

unread,
Aug 13, 2019, 4:01:59 PM8/13/19
to games...@gmail.com, adwor...@googlegroups.com
Hello,

Since you are using the APP campaigns it wont support the specific ad status field. Since the Ads  for APP campaings shows using the asserts uploaded and they cannot be paused. So you can pause at the AdGroup and campaign levels only for APP campaigns. Please let me know if you have any further questions.

This part of code snippet causing the issue:  " 'status' => AdGroupAdStatus::PAUSED,"

Regards,
Sai Teja, Google Ads API Team
 

ref:_00D1U1174p._5001UEIiNN:ref

MCC智美

unread,
Aug 14, 2019, 3:25:54 AM8/14/19
to AdWords API and Google Ads API Forum
Hello,

Thank you for your guidance.This problem has been solved.
Reply all
Reply to author
Forward
0 new messages