def create_campaign(
client: GoogleAdsClient, customer_id: str, campaign_budget: str
) -> str:
"""Creates campaign resource.

Args:
client: an initialized GoogleAdsClient instance.
customer_id: a client customer ID.
campaign_budget: a budget resource name.

Returns:
Campaign resource name.
"""
campaign_service: CampaignServiceClient = client.get_service(
"CampaignService"
)
campaign_operation: CampaignOperation = client.get_type("CampaignOperation")
campaign: Campaign = campaign_operation.create
campaign.name = f"Testing RSA via API {uuid.uuid4()}"
campaign.advertising_channel_type = (
client.enums.AdvertisingChannelTypeEnum.SEARCH
)

# Recommendation: Set the campaign to PAUSED when creating it to prevent
# the ads from immediately serving. Set to ENABLED once you've added
# targeting and the ads are ready to serve.
campaign.status = client.enums.CampaignStatusEnum.PAUSED

# Set the bidding strategy and budget.
# The bidding strategy for Maximize Clicks is TargetSpend.
# The target_spend_micros is deprecated so don't put any value.
# See other bidding strategies you can select in the link below.
# 
https://developers.google.com/google-ads/api/reference/rpc/latest/Campaign#campaign_bidding_strategy
campaign.target_spend.target_spend_micros = 0
campaign.campaign_budget = campaign_budget

# Set the campaign network options.
campaign.network_settings.target_google_search = True
campaign.network_settings.target_search_network = True
campaign.network_settings.target_partner_search_network = False
# Enable Display Expansion on Search campaigns. For more details see:
# https://support.google.com/google-ads/answer/7193800
campaign.network_settings.target_content_network = True

# # Optional: Set the start date.
# start_time = datetime.date.today() + datetime.timedelta(days=1)
# campaign.start_date = datetime.date.strftime(start_time, _DATE_FORMAT)

# # Optional: Set the end date.
# end_time = start_time + datetime.timedelta(weeks=4)
# campaign.end_date = datetime.date.strftime(end_time, _DATE_FORMAT)

# Add the campaign.
campaign_response: MutateCampaignsResponse = (
campaign_service.mutate_campaigns(
customer_id=customer_id, operations=[campaign_operation]
)
)
resource_name: str = campaign_response.results[0].resource_name
print(f"Created campaign {resource_name}.")
return resource_name

The above is my code, which I copied from the official documentation, but 
encountered an error when executed FaultMessage: The required field was not 
present

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/adwords-api/6383a7dc-2d8e-4191-89bb-5ea1c9143e5en%40googlegroups.com.
  • &q... 주식회사노먼
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
    • ... 'feng chen' via Google Ads API and AdWords API Forum
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to