Error in AdServingOptimizationStatusEnum

20 views
Skip to first unread message

Pratham Chauhan

unread,
Aug 6, 2024, 4:54:26 AM8/6/24
to Google Ads API and AdWords API Forum
Hi there,
I have been trying to add Ad serving optimization status to optimise as specified here. But is giving me the error for all the options except UNSPECIFIED option. I am attaching the code for reference :

check for this line
campaign.ad_serving_optimization_status = client.enums.AdServingOptimizationStatusEnum.OPTIMIZE
# creates a campaign
def create_campaign(client, customer_id, campaign_budget):
"""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 = client.get_service("CampaignService")
campaign_operation = client.get_type("CampaignOperation")
campaign = campaign_operation.create
campaign.name = f"Complete campaign creation workflow with optimisation {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.ENABLED

# 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.
campaign.target_spend.target_spend_micros = 0
campaign.campaign_budget = campaign_budget

# set the ad rotation status
campaign.ad_serving_optimization_status = client.enums.AdServingOptimizationStatusEnum.OPTIMIZE

# 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:
campaign.network_settings.target_content_network = False

# # 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 = campaign_service.mutate_campaigns(
customer_id=customer_id, operations=[campaign_operation]
)
resource_name = campaign_response.results[0].resource_name
print(f"Created campaign {resource_name}.")
return resource_name

Google Ads API Forum Advisor

unread,
Aug 6, 2024, 9:08:24 AM8/6/24
to chauhanp...@gmail.com, adwor...@googlegroups.com
Hi,

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

To analyze the issue further, please share with us the complete API logs (request and response with request-id and request header) generated at your end.

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 guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

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.!5004Q02vEbAQ:ref" (ADR-00261190)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages