Setting bidding strategy to target CPA

78 views
Skip to first unread message

Yigitalp (Alp) Korpe

unread,
Oct 2, 2024, 8:25:27 AM10/2/24
to Google Ads API and AdWords API Forum
Hi Team, 

I want to set my campaign's bid strategy to Target CPA but I am getting following error. Could you please help me on it? 
FaultMessage: The operation is not allowed for the given context.
Request with ID '****' failed with status 'INVALID_ARGUMENT' and includes the following errors:
        Error with message 'The operation is not allowed for the given context.'.

please find the code below
campaign_service = client.get_service("CampaignService")
campaign_operation = client.get_type("CampaignOperation")
campaign = campaign_operation.update
campaign.resource_name = campaign_resource_name
campaign.bidding_strategy_type = (
client.enums.BiddingStrategyTypeEnum.TARGET_CPA
)
campaign.target_cpa.target_cpa_micros = 35000000

# Set the update mask.
client.copy_from(
campaign_operation.update_mask,
protobuf_helpers.field_mask(None, campaign._pb),
)

try:
# Issue a mutate request to update the campaign.
campaign_response = campaign_service.mutate_campaigns(
customer_id=account.id, operations=[campaign_operation]
)

Matt Dworkin

unread,
Oct 2, 2024, 11:28:41 AM10/2/24
to Google Ads API and AdWords API Forum
We also started getting this same error this morning when trying to do the same thing in the PHP SDK. Changing the bid strategy from max cv -> TCPA worked yesterday and last week, but now we get this error. Did something change in the API?

Google Ads API Forum Advisor

unread,
Oct 3, 2024, 2:59:45 PM10/3/24
to mdwor...@gmail.com, adwor...@googlegroups.com
Hi,

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

After reviewing your concern, I understand that you are getting an INVALID_ARGUMENT error. In order to debug the issue, please provide us with 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, .Net, PHP, Python, Ruby 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.!5004Q02vGbrY:ref" (ADR-00270392)

Thanks,
 
Google Logo Google Ads API Team


 

Google Ads API Forum Advisor

unread,
Oct 3, 2024, 4:53:42 PM10/3/24
to adwor...@googlegroups.com

Hi,

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

To investigate your issue further, kindly provide the complete API logs (request and response logs with request-id and request header) generated at your end when setting bidding strategy to target CPA via the API so that we can check the complete request and response of the API call and get back to you.

If you are using a client library and haven't enabled the logging yet, I would request that you 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.!5004Q02vGbpr:ref" (ADR-00270376)


Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages