在 Google Ads API 中,某些消息字段被定义为空消息对象(例如 campaign.manual_cpm),或者可能仅包含不需要设置的可选字段(例如 campaign.manual_cpc)。设置这些字段非常重要,因为这有助于告知 API 应为给定广告系列使用哪种出价策略,但如果消息为空,则不直观。
from google.api_core.protobuf_helpers import field_mask
campaign_operation.create = campaign
campaign_operation.update_mask = field_mask(None, campaign)
# Here we manually add the "manual_cpm" field
campaign_operation.update_mask.append("manual_cpm")
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-11-24。"],[[["Some Google Ads API message fields are defined as empty or only have optional fields, requiring specific handling to indicate the intended bidding strategy."],["To set a bidding strategy using an empty message field (like `manual_cpm`), you need to copy a separate empty instance of the corresponding class onto the campaign object."],["Nested fields within messages (like `campaign.manual_cpc.enhanced_cpc_enabled`) can be updated directly like normal Python object attributes."],["When using empty message objects, ensure the field is added to the request's `update_mask` manually, as the field mask helper cannot automatically detect this."]]],[]]