Hello,
At the bottom of my email, I will share my code.
I am reaching out because I receive an error when attempting to update
final_url at the adgroup_ad level.
*My code sends operations to your server, like this:*
update_mask {
....paths: "resource_name"
....paths: "final_urls"
}
update {
....resource_name: "customers/0000000000/ads/000941170000"
....final_urls: "https://www.example.app/"
}
*and receives this response:*
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:142.250.72.170:443
{created_time:"2023-04-04T22:59:21.263110704+00:00", grpc_status:3,
grpc_message:"Request contains an invalid argument."}" >,
<_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:142.250.72.170:443
{created_time:"2023-04-04T22:59:21.263110704+00:00", grpc_status:3,
grpc_message:"Request contains an invalid argument."}" >,
errors {
....error_code {
........ad_error: CANNOT_MODIFY_AD
....}
....message: "Cannot modify an ad."
....location {
........field_path_elements { field_name: "operations" index: 0 }
....}
}
*It seems like the server is refusing. Please see also my code below:*
customer_id = '0000000000'
client = pipeline.gads_pipe.handle.client.client
def update_ad_links(customer_id, client, updates_df):
....operations = []
....for row in updates_df.to_dict('records'):
........ad_op = client.get_type('AdOperation')
........ad = ad_op.update
........
........ad.resource_name = row['ad_group_ad.ad.resource_name']
........ad.final_urls = row['new_links']....
........operations.append(ad_op)
........
........fm = protobuf_helpers.field_mask(None, ad_op._pb)
........
........# Fixed a glitch... Converts 'update.final_urls' to 'final_urls'
........for index, path in enumerate(fm.paths):
............clean_path = path.split('.')[-1]
............fm.paths[index] = clean_path
............
........client.copy_from(
............ad_op.update_mask,
............fm
........)
....ad_service = client.get_service('AdService')
....response = ad_service.mutate_ads(customer_id=customer_id,
operations=operations)
....
....return response
Any idea what is going on?
By the way, the for loop with the comment saying "Fixed bug", that is
because the update mask was made wrong... It came out like this by default
(immediately fails):
update_mask {
....paths: "update.resource_name"
....paths: "update.final_urls"
}
update {
....resource_name: "customers/0000000000/ads/000941170000"
....final_urls: "https://www.example.app/"
}
So, the for loop is fixing that bug.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/d4dabfc5-d99a-44d5-a85b-f5c989ee5297n%40googlegroups.com.