AdsApp.mutate() proxy to API's mutate method

66 views
Skip to first unread message

Sergei Aleinik

unread,
Jul 19, 2023, 2:26:25 PM7/19/23
to Google Ads Scripts Forum
Hello! You've introduced new method `mutate()` on the scripts. Documentation says that it uses objects as defined in the Google Ads API REST Interface.

Perfect! It will help us to optimize a plenty of scripts. But there is one thing that haunts me.

Why do you restrict mutations on video objects through real API (https://developers.google.com/google-ads/api/docs/start), meanwhile permit to mutate them on the scripts?

Check the next two snippets.

This is the Google Ads Scripts
function main() {
 AdsManagerApp.select(AdsManagerApp.accounts().withIds([6777740344]).get().next());
 
  const createAdGroupResponse = AdsApp.mutate(
  {
    adGroupOperation: {
      create: {
        campaign: `customers/6777740344/campaigns/20367702619`,
        name: 'My Ad Group Name',
        cpvBidMicros: '1230000',
        type: 10
      }
    }
  });
 
  console.log(createAdGroupResponse.getErrorMessages());
}


This the Google Ads API (official PHP library, gRPC)
        $mutate    = new MutateOperation();
        $operation = new AdGroupOperation();
        $adGroup   = new AdGroup();

        $mutate->setAdGroupOperation($operation);
        $operation->setCreate($adGroup);

        $adGroup->setName('My Ad Group Name');
        $adGroup->setCampaign(ResourceNames::forCampaign('6777740344', '20367702619'));
        $adGroup->setCpvBidMicros(1230000);
        $adGroup->setType(AdGroupType::VIDEO_TRUE_VIEW_IN_DISPLAY); // 10

        $response = $client->mutate('6777740344', [$mutate]);


I believe that both snippets do pretty same things under the hood. But the problem is that the API (php snippet) fails with exception:
Mutates are not allowed for the requested resource.
trigger.stringValue: VIDEO

While the Scripts snippet creates AdGroup impeccably. What the reason of this sort of restrictions?

Google Ads Scripts Forum Advisor

unread,
Jul 20, 2023, 1:45:10 AM7/20/23
to adwords...@googlegroups.com

Hi Sergei,

 

Thank you for reaching out to the Google Ads Scripts Support Team.

 

We're glad that you were able to make use of the new feature in Google Ads Scripts without any issues, as I observed you had tried to create a video ad group. However, it does appear that your concern is regarding the Google Ads API's functionality and restrictions which we would be unable to further comment on. In the Google Ads Scripts perspective, generic mutates does enforce the same mutate operation or service that's being used via API.

 

That being said, I believe it's best that you reach out to their API support team by posting on the Google Ads API public forum so you're able to receive further insights as to why the request you had made using the aforementioned API encounters an error as well as it's restrictions. I've included a link below which you may navigate to.

 

In the meantime, you may opt to create the entity via Google Ads Scripts. If you would need any further assistance from our team regarding Google Ads Scripts or encounter any issues, please let us know so we're able to assist you accordingly.

 

Relevant links:

 

This message is in relation to case "ref:_00D1U1174p._5004Q2n9acy:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages