JSON for updating campaign

101 views
Skip to first unread message

Allen Fey

unread,
Jun 26, 2019, 6:13:19 AM6/26/19
to AdWords API and Google Ads API Forum
I have a situation where I can not use one of the libraries so I am trying to figure out the JSON to update campaigns. I am able to use the query language to retreive data, but am getting caught on the mutate services.

For example, when I post the following JSON to: https://googleads.googleapis.com/v1/customers/{account number}/campaigns:mutate 
{
 
"operations": [
   
{
     
"update": {
       
"resourceName": "customers/{account number}/campaigns/{campaign ID}",
       
"status": "PAUSED"
     
}
   
}
 
]
}



I receive the following response:
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "errors": [
          {
            "errorCode": {
              "fieldMaskError": "FIELD_MASK_MISSING"
            },
            "message": "Cannot use empty field mask in update operation.",
            "location": {
              "fieldPathElements": [
                {
                  "fieldName": "operations",
                  "index": "0"
                }
              ]
            }
          }
        ]
      }
    ]
  }
}

I am unsure how to set the field mask in the Google ads API so that I am indicating I am only updating the campaign status field. I can't find much JSON documentation for the ads API and have tried several different ways without much luck, so any help is appreciated.

Thanks.

Google Ads API Forum Advisor Prod

unread,
Jun 26, 2019, 3:18:50 PM6/26/19
to afey...@gmail.com, adwor...@googlegroups.com

Hi Allen,

Thank you for contacting support. I tried updating campaign using code sample from Java Client libraries and have attached logs. From the logs, you can see that you need to use update_mask field to perform update operation. Please refer to this guide for more information on field mask and code sample to update campaigns. Let us know if you need additional information.

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001UCZZUS:ref
Update_Campaign_logs

Allen Fey

unread,
Jun 26, 2019, 5:09:20 PM6/26/19
to AdWords API and Google Ads API Forum
Thank you Nikisha, that was a tremendous help!

Just in case anyone stumbles across this in the future, I did need to make a couple of tweaks to the JSON from the log file to get it to work. Here is what worked for me:

{
 
"operations": {
     
"update": {
       
"resourceName": "customers/{Account Number/campaigns/{Campaign Number}",
       
"status": "PAUSED"
       
},
       
"update_mask": {
       
"paths": "resource_name",
       
"paths": "status"
       
}
   
}
}
Reply all
Reply to author
Forward
0 new messages