Update target roas in campaign

289 views
Skip to first unread message

Siebert Looije

unread,
Jan 4, 2024, 9:57:51 AM1/4/24
to Google Ads API and AdWords API Forum
Hi,

I am trying to update the target roas with the API. However I get the following error message: 


GoogleAdsException:
(<_InactiveRpcError of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Request contains an invalid argument." debug_error_string = "UNKNOWN:Error received from peer ipv4:74.125.193.95:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2024-01-04T14:51:29.347713307+00:00"}" >, <_InactiveRpcError of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Request contains an invalid argument." debug_error_string = "UNKNOWN:Error received from peer ipv4:74.125.193.95:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2024-01-04T14:51:29.347713307+00:00"}" >, errors { error_code { context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT } message: "The operation is not allowed for the given context." trigger { string_value: "EXPRESS(EXPRESS_SMART)" } location { field_path_elements { field_name: "operations" index: 0 } field_path_elements { field_name: "update" } field_path_elements { field_name: "maximize_conversion_value" } field_path_elements { field_name: "target_roas" } } } request_id: "fZX_kkC8f6ABE5BOoQspwQ" , 'fZX_kkC8f6ABE5BOoQspwQ')

Code first try:
customer_id = str(customer_id)
# Create the appropriate service and operation based on entity_type
service = client.get_service("CampaignService")
operation = client.get_type("CampaignOperation")
update = operation.update
update.resource_name = service.campaign_path(
customer_id, campaign_id
)
update.maximize_conversion_value.target_roas = target_roas
client.copy_from(
operation.update_mask,
protobuf_helpers.field_mask(None, update._pb),
)

response = service.mutate_campaigns(customer_id=customer_id, operations=[operation]) code second try (changing the update field):
# Cast to string
customer_id = str(customer_id)
# Create the appropriate service and operation based on entity_type
service = client.get_service("CampaignService")
operation = client.get_type("CampaignOperation")
update = operation.update
update.resource_name = service.campaign_path(
customer_id, campaign_id
)
update.target_roas.target_roas = target_roas
client.copy_from(
operation.update_mask,
protobuf_helpers.field_mask(None, update._pb),
)

response = service.mutate_campaigns(customer_id=customer_id, operations=[operation])
print('Updated campaign %s.' % response.results[0].resource_name)
I am following the references in the google ads API and they suggest to use these code. Thanks for the help! Kind regards,
Siebert

Google Ads API Forum Advisor

unread,
Jan 4, 2024, 11:16:34 AM1/4/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi,

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

By reviewing your concern, I understand that you are getting an "OPERATION_NOT_PERMITTED_FOR_CONTEXT" error.

Upon checking, I understand you have provided the error logs but kindly note that error logs are not sufficient to investigate the issue so please provide us complete API logs (request and response with request-id and request header) generated at your end and uncropped UI screenshot of the Google Ads account where you are facing the issue.

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.!5004Q02r5NWk:ref"

Thanks,
 
Google Logo Google Ads API Team


Siebert Looije

unread,
Jan 4, 2024, 12:22:31 PM1/4/24
to Google Ads API and AdWords API Forum
Hi,

The request id is fZX_kkC8f6ABE5BOoQspwQ. Is this enough or do you need more from my side?
Kind regards,

Siebert

Op donderdag 4 januari 2024 om 17:16:34 UTC+1 schreef Google Ads API Forum Advisor:

Google Ads API Forum Advisor

unread,
Jan 4, 2024, 1:50:53 PM1/4/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi Siebert,

Thank you for getting back to us.

To investigate this issue further, please provide us with the complete API logs (request and response with request-id and request header) generated at your end along with the uncropped UI screenshot (with visible customer Id) to better assist you on this request. 


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. 
 

Siebert Looije

unread,
Jan 8, 2024, 9:50:42 AM1/8/24
to Google Ads API and AdWords API Forum
Hi, 

Below is the request and request header:
------ Method: /google.ads.googleads.v14.services.CampaignService/MutateCampaigns Host: googleads.googleapis.com Headers: { "developer-token": "REDACTED", "x-goog-api-client": "gl-python/3.10.12 grpc/1.48.1 gax/2.8.2 gccl/21.2.0 pb/4.25.1", "x-goog-request-params": "customer_id=5901767327" } Request: customer_id: "5901767327" operations { update_mask { paths: "resource_name" paths: "target_roas.target_roas" } update { resource_name: "customers/5901767327/campaigns/16501417569" target_roas { target_roas: 1 } } } Response ------- Headers: { "google.ads.googleads.v14.errors.googleadsfailure-bin": "\ne\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\")\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\r\n\u000btarget_roas\u0012\u0016wngBTHJ59-u7Hyek-RpttQ", "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nDtype.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure\u0012 \ne\n\u0003\u0003\u0002\u00123The operation is not allowed for the given context.\")\u0012\u000e\n\noperations\u0018\u0000\u0012\b\n\u0006update\u0012\r\n\u000btarget_roas\u0012\u0016wngBTHJ59-u7Hyek-RpttQ", "request-id": "wngBTHJ59-u7Hyek-RpttQ" } Fault: errors { error_code { context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT } message: "The operation is not allowed for the given context." location { field_path_elements { field_name: "operations" index: 0 } field_path_elements { field_name: "update" } field_path_elements { field_name: "target_roas" } } } request_id: "wngBTHJ59-u7Hyek-RpttQ" [2024-01-08 14:38:51,271 - WARNING] Request made: ClientCustomerId: 5901767327, Host: googleads.googleapis.com, Method: /google.ads.googleads.v14.services.CampaignService/MutateCampaigns, RequestId: wngBTHJ59-u7Hyek-RpttQ, IsFault: True, FaultMessage: The operation is not allowed for the given context.
And in the attachment is the UI I am using. There is no UI from the google ads manager. Is this enough or do you need more?

Kind regards,

Siebert Looije


Op donderdag 4 januari 2024 om 19:50:53 UTC+1 schreef Google Ads API Forum Advisor:
Naamloos.png

Google Ads API Forum Advisor

unread,
Jan 8, 2024, 2:03:05 PM1/8/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi,

Thank you for providing more information.

I have raised your concern with the rest of our team and one of my teammates will reach out to you once we have an update.

Md Kamal Hossain

unread,
Jan 9, 2024, 1:43:48 PM1/9/24
to Google Ads API and AdWords API Forum
hi

Siebert Looije

unread,
Jan 11, 2024, 4:50:02 PM1/11/24
to Google Ads API and AdWords API Forum
Hi,

Thanks for looking into this.
Is there any update regarding this?

Kind regards,

Siebert

Op maandag 8 januari 2024 om 20:03:05 UTC+1 schreef Google Ads API Forum Advisor:

Google Ads API Forum Advisor

unread,
Jan 12, 2024, 2:30:23 PM1/12/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi Siebert, my name is Devin, and I've been looking into your case.

Our engineering team is currently investigating the issue, and I will reach back out as soon as I learn more.

All the best,
Devin

ref:!00D1U01174p.!5004Q02r5NWk:ref

Siebert Looije

unread,
Jan 16, 2024, 6:36:42 AM1/16/24
to Google Ads API and AdWords API Forum
Hi Devin,

Thanks for picking this up.
Is there any news on this?

Kind regards,

Siebert

Op vrijdag 12 januari 2024 om 20:30:23 UTC+1 schreef Google Ads API Forum Advisor:

Siebert Looije

unread,
Jan 19, 2024, 12:49:51 PM1/19/24
to Google Ads API and AdWords API Forum
Hi Devin,

What is the expected time that there will be an update on this? 
For us it is important feature which can benefit a lot to our product.

Kind regards,

Siebert Looije

Op dinsdag 16 januari 2024 om 12:36:42 UTC+1 schreef Siebert Looije:

Google Ads API Forum Advisor

unread,
Jan 25, 2024, 4:58:05 PM1/25/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi Siebert,

Apologies for the delay. We had the relevant team take a look at this issue. This campaign is a Google Express campaign, and it doesn't support target_roas as a bidding strategy.

We will add more detailed documentation around this topic.

Regards
Anash

ref:!00D1U01174p.!5004Q02r5NWk:ref

Siebert Looije

unread,
Jan 25, 2024, 6:58:59 PM1/25/24
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Hi Anash,

Thanks for looking into this. So can you explain to me which type of campaign I can use to try it out? 
Furthermore, the way how I was doing it is still correct (the sample code?)

Kind regards,

Siebert Looije

Op do 25 jan 2024 om 22:57 schreef Google Ads API Forum Advisor <ads...@forumsupport.google>:


--

Met vriendelijke groeten / Kind Regards,

 

Siebert Looije

Tech lead & Senior Data scientist


Email: siebert...@billygrace.com

Website: www.billygrace.com  


Professor Tulpstraat 18, 1018 HA,

Amsterdam, The Netherlands


Google Ads API Forum Advisor

unread,
Jan 25, 2024, 7:17:13 PM1/25/24
to siebert...@billygrace.com, adwor...@googlegroups.com
Hi Siebert,

You can look at https://support.google.com/google-ads/answer/6268637?hl=en for the campaign types that support target_roas. A display campaign is probably the easiest way. You can try this out on the test account UI to be sure.

Yes, the code is fine. It is failing only because of the campaign type mismatch as far as I can tell.
Reply all
Reply to author
Forward
0 new messages