Google Ads API Updated REST resources

167 views
Skip to first unread message

Steve Wilcox

unread,
Sep 22, 2020, 10:37:11 AM9/22/20
to AdWords API and Google Ads API Forum
Greetings and Salutations, Ads Gurus!

My organization is working on a REST integration with Google Ads (not using the client libraries) and we are stumbling through finding the right process to programattically link a client ads account to a manager account, and add and remove ads campaigns from those client ads accounts.  

One of those process appears to be detailed exhaustively here:
https://developers.google.com/google-ads/api/docs/rest/common/mutate

However, the mutate JSON provided to update a campaign:
{
  "operations": [
    {
      "updateMask": "campaign.name,campaign.status",
      "update": {
        "resourceName": "customers/1234567890/campaigns/8765432109",
        "name": "My renamed campaign",
        "status": "PAUSED",
      }
    }
  ]
}
  
is not correct (or at least I couldn't get it to work).  The version that I HAVE gotten to work looks like this:
{
  "operations": [
    {
      "updateMask": "name,status",
      "update": {
        "resourceName": "customers/<account id>/campaigns/<campaign id>",
        "name": "<new name>",
        "status": "PAUSED",
      }
    }
  ]
}

The differences are subtle, but finding out what works and what doesn't is an exhausting process and, frankly, we don't have time to do it.  We have made precisely no progress on linking campaigns or removing campaigns.

I can use https://developers.google.com/google-ads/api/docs/query/interactive-gaql-builder to build queries and explore table structures.

Is there an up-to-date reference for the REST interface and how the mutates JSONs are to be built?

Thanks in Advance!

David Scott

unread,
Sep 22, 2020, 12:00:28 PM9/22/20
to AdWords API and Google Ads API Forum
Here is my perl code that works:
$command = qq(curl -X POST \\
  https://googleads.googleapis.com/v5/customers/$customer/campaigns:mutate \\
  -H 'Authorization: Bearer $access_token' \\
  -H 'Content-Type: application/json' \\
  -H 'developer-token: $DEVELOPER_TOKEN' \\
  -H 'login-customer-id: $MANAGER_CUSTOMER_ID' \\
  -d '{
  "operations":
  [
    {
      "updateMask": "name,status,campaignBudget,networkSettings(),servingStatus,biddingStrategyType,geoTargetTypeSetting()",
      "update":
      {
        "resourceName": "customers/$customer/campaigns/$test4",
         "id": "$test4",
         "name": "test4",
         "status": "PAUSED",
         "campaignBudget": "customers/$customer/campaignBudgets/1216493989",
         "networkSettings":
         {
           "targetGoogleSearch": true,
           "targetSearchNetwork": true,
           "targetContentNetwork": false,
           "targetPartnerSearchNetwork": false
         },
         "servingStatus": "SERVING",
         "biddingStrategyType": "TARGET_SPEND",
         "geoTargetTypeSetting":
         {
           "positiveGeoTargetType": "PRESENCE"
         }
      }
    }
  ]
}');

@result = qx{$command};
print "@result\n";

Steve Wilcox

unread,
Sep 22, 2020, 12:11:50 PM9/22/20
to AdWords API and Google Ads API Forum
Hey, thanks for responding!

Do you happen to have one for deleting campaigns?  I can get altering one to work.

Google Ads API Forum Advisor Prod

unread,
Sep 22, 2020, 2:46:25 PM9/22/20
to swi...@convoyant.com, adwor...@googlegroups.com
Hey Steve,

You can refer to this example which shows how to remove a campaign.

Let me know if you have any other issues.

Cheers,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q25Vu1A:ref

Steve Wilcox

unread,
Sep 22, 2020, 2:53:07 PM9/22/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hi Anthony,

This example is on the page I linked to in the original post.  It doesn't work.  None of them do, at least not as written.

This particular one fails with: "description": "Invalid JSON payload received. Unknown name \"resourceName\" at 'operations[0].remove': Cannot find field."

I've tried with resourceID and name with basically identical results.


--
Steve Wilcox
Developer | ResNexus

Google Ads API Forum Advisor Prod

unread,
Sep 23, 2020, 11:53:14 AM9/23/20
to swi...@convoyant.com, adwor...@googlegroups.com
Hi Steve,

Can you please reply privately to author the request and response you made for this call?

Thanks,

Steve Wilcox

unread,
Sep 23, 2020, 12:19:00 PM9/23/20
to AdWords API and Google Ads API Forum

Anthony,

More than happy to.  I'm new to groups and the Reply to Author button is grayed out.  The tool tip says both that I don't have permissions to do so in this forum AND that I need to set my browser up to handle mailto links.  The latter is already true, for certain.  

Google Ads API Forum Advisor Prod

unread,
Sep 23, 2020, 3:35:14 PM9/23/20
to swi...@convoyant.com, adwor...@googlegroups.com
Hi Steve,

You can email us directly at googleadsa...@google.com if you are unable to reply privately.

Regards,
Reply all
Reply to author
Forward
0 new messages