Mutate keywords with Rest on google ads api

80 views
Skip to first unread message

Antonio Cortina

unread,
Dec 28, 2020, 7:33:56 AM12/28/20
to AdWords API and Google Ads API Forum
Hi,

Im new using google ads api with REST and im triying to mutate added keywords from ads console.

I can modify status because its in the same object of adGroupCriterion but keyword data its on an object keyword, keyword['text'] and keyword['matchType'].

How can i modify them?

This is my code

    const url = 'https://googleads.googleapis.com/v6/customers/' + dataIn.customerId + '/adGroupCriteria:mutate';

    let data = { 
      "operations": [
        { 
          "updateMask": "status",
          "update": {
            "resourceName": dataIn.adGroupCriterion['resourceName'],
            "status": dataIn.adGroupCriterion['status']
          } 
        } 
      ] 
    };

DOESNT WORK

    let data = {
      "operations": [
        {
          "updateMask": "text, matchType,status",
          "update": {
            "resourceName": dataIn.adGroupCriterion['resourceName'],
            "text": dataIn.adGroupCriterion['keyword']['text'],
            "matchType": dataIn.adGroupCriterion['keyword']['matchType'],
            "status": dataIn.adGroupCriterion['status']
          }
        }
      ]
    };

Thanks

Google Ads API Forum Advisor Prod

unread,
Dec 29, 2020, 12:15:49 PM12/29/20
to antco...@gmail.com, adwor...@googlegroups.com
Hi Antonio,

Thanks for reaching out. We recommend using the client libraries for basic tasks, such as updating a keyword. You can find a code example for updating keywords from the client libraries here.

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q29VGJt:ref

Antonio Cortina

unread,
Dec 29, 2020, 12:35:50 PM12/29/20
to AdWords API and Google Ads API Forum
Hi,

Thanks for your response. Im using javascript/node and I cant see any client library.

In any case, im interested in use REST and not client because im using several google apis in the same way.

Can you help me about modify keywords with REST?

Thanks

Antonio Cortina

unread,
Dec 29, 2020, 10:42:57 PM12/29/20
to AdWords API and Google Ads API Forum
Hi,

Im reading about it, and I think that keyword.text and keyword.matchType are immutables. Is it possible?

Keyword field is an union field criterion from AdGroupCriteria:

https://developers.google.com/google-ads/api/reference/rpc/v6/AdGroupCriterion#criterion

And all of these are immutables, so I can create and remove keywords but not modify them from API, is it right?

In Google Ads console I can modify them but I think that really it remove the old one and creates new one.

Can you confirm this?

Thanks

Google Ads API Forum Advisor Prod

unread,
Dec 30, 2020, 1:53:58 PM12/30/20
to antco...@gmail.com, adwor...@googlegroups.com
Hi Antonio,

Yes, that's correct -- immutable fields cannot be changed (fields described as 'output only' in the documentation will also be ignored for mutate requests). More information on this can be found in the Changing and Inspecting Objects guide.
Reply all
Reply to author
Forward
0 new messages