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
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 on the web visit
https://groups.google.com/d/msgid/adwords-api/5226722f-3d3e-4cee-aab1-b178abe62078n%40googlegroups.com.