Can't update an existing campaign's priority to "Low" via the Ads API

39 views
Skip to first unread message

mha...@simplepart.com

unread,
Jul 19, 2024, 5:47:11 PM7/19/24
to Google Ads API and AdWords API Forum
I use the Google Ads API Python client library and am having a difficult time setting the campaign priority of an existing campaign to be "Low" (0) via the Ads API. I can change it to "High" (2) but not to "Low". Here's the relevant chunk of my code:

campaign_service = client.get_service("CampaignService")
campaign_operation = client.get_service("CampaignOperation")
campaign = campaign_operation.update
campaign.resource_name = campaign_service.campaign_path(
    customerId, campaignId)
campaign.shopping_setting.campaign_priority = 0
client.copy_from(
    campaign_operation.update_mask,
    protobuf_helpers.field_mask(None, campaign._pb),
)
campaign_service.mutate_campaigns(customer_id=customerId, operations=[campaign_operation])
 
I think the issue traces back to the protobuf_helpers.field_mask() function not adding "campaign_priority.shopping_setting" to the paths field of the mutate - the only item that shows up in the paths when my current code runs is "resource_name". Does it read "0" as being a null field? Any suggestions as to how I can make this mutate happen? If this were a one-off I'd do it in the UI, but it's something I'm gonna need to do across a ton of different accounts and campaigns. Thanks.

Google Ads API Forum Advisor

unread,
Jul 22, 2024, 1:05:14 AM7/22/24
to mha...@simplepart.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

I would suggest you refer to the document Automatic steps to get more information on how to set campaign priority with the Google Ads API. 

If you are still facing the issues, please share the complete API logs (requestresponserequest-id and request header) generated on your device with us. 

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guide Python to enable logging at your end. You can enable logging via the curl command by using the -i flag for REST interface requests.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vDrFV:ref" (ADR-00253691)

Thanks,
 
Google Logo Google Ads API Team


asif...@instaview365.com

unread,
Jul 22, 2024, 1:37:47 AM7/22/24
to adwor...@googlegroups.com

Dear 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum,


We would like to acknowledge that we have received your request and a ticket has been created.

A support representative will be reviewing your request and will send you a personal response (usually within 24 hours).



Thank you for your patience.


Sincerely,

asif...@instaview365.com

mha...@simplepart.com

unread,
Jul 22, 2024, 10:44:13 AM7/22/24
to Google Ads API and AdWords API Forum
Thanks for the link to the "Automatic steps" document. The steps described there did not solve the problem, which seems to specifically stem from the setting for "Low" being the integer 0. However, I just figured out a way to make it work -- namely, instead of using the client.copy_from() function that I used in the code I shared previously, I manually set the "paths" for the mutate request with a Python dictionary object specifying the fields in question, so that it wouldn't ignore the new value set for "campaign_priority". This is what the modified, successful mutate looks like (updated part is highlighted):

campaign_service = client.get_service("CampaignService")
campaign_operation = client.get_type("CampaignOperation")
campaign = campaign_operation.update
campaign.resource_name = campaign_service.campaign_path(
    googleAdsId, campaignId
)
campaign.shopping_setting.campaign_priority = 0
campaign_operation.update_mask = {
    'paths': ['resource_name', 'shopping_setting.campaign_priority']
}
response = campaign_service.mutate_campaigns(
    customer_id=googleAdsId,
    operations=[campaign_operation]
)

Google Ads API Forum Advisor

unread,
Jul 22, 2024, 3:28:17 PM7/22/24
to mha...@simplepart.com, adwor...@googlegroups.com
Hi,

To assist you further, kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end. This would help us investigate this issue further.


You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vDrFV:ref" (ADR-00253691)

Thanks,

 
Google Logo Google Ads API Team

Register for the upcoming workshop: Performance Max and the Google Ads API!
 


Reply all
Reply to author
Forward
0 new messages