Attempting to Modify an Ads final_url value fails. Also, possible bug found || ad_error: CANNOT_MODIFY_AD

230 views
Skip to first unread message

Chad Wood

unread,
Apr 4, 2023, 8:02:26 PM4/4/23
to Google Ads API and AdWords API Forum
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.

Google Ads API Forum Advisor

unread,
Apr 5, 2023, 5:47:21 AM4/5/23
to chadwo...@gmail.com, adwor...@googlegroups.com

Hi Chad,

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

Since you are using AdService, kindly note that updating ads is not supported for TextAd, ExpandedDynamicSearchAd, GmailAd and ImageAd as you can see in the description of the MutateAds method.

If you are encountering errors even for ad types where update is supported, please provide the complete request and response logs, with the request-id so we can further investigate. If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.You can provide it to us using the Reply privately to author option.

Thanks,

Google Logo Google Ads API Team


ref:_00D1U1174p._5004Q2kFRLt:ref

Chad Wood

unread,
Apr 5, 2023, 12:09:10 PM4/5/23
to Google Ads API and AdWords API Forum
Thanks.  Are there any workarounds? Maybe a different API?

We've got about 400 image ads, and one of the team members hardcoded utm parameters into the final urls. We use a tracking template though, and these hardcoded parameters are damaging to data quality.

I'm hoping we can avoid needing to manually update every ad's final url through the web portal.

Google Ads API Forum Advisor

unread,
Apr 5, 2023, 4:42:21 PM4/5/23
to chadwo...@gmail.com, adwor...@googlegroups.com

Hello,

Thank you for getting back to us.

Please note that the Google Ads API manages accounts from the customer level down to the keyword level. The API can do what the Google Ads UI does, but programmatically. So there is no other API that can be used to modify your Ad.

I would really like to investigate this error further, would you please provide us with the complete request and response logs with request ID generated as shown in the respective links, so we can check on our end the errors being thrown?

If you haven't enabled logging yet, it can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation(via this link https://developers.google.com/google-ads/api/docs/best-practices/logging#client_library_logging), which you can access from this link. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com

Reference Links:
Request - https://developers.google.com/google-ads/api/docs/concepts/field-service#request
Response Logs - https://developers.google.com/google-ads/api/docs/concepts/field-service#response
Request ID - https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id

Regards,

Chad Wood

unread,
Apr 5, 2023, 6:25:37 PM4/5/23
to Google Ads API and AdWords API Forum
Based on your explanation, it sounds like the error I've received is the expected behavior.
By my understanding, the API does not support our need and there are no alternatives.


"Since you are using AdService, kindly note that updating ads is not supported for TextAd, ExpandedDynamicSearchAd, GmailAd and ImageAd"
and "So there is no other API that can be used to modify your Ad."

So, if I may ask, what is left to investigate? How would be logs help do anything beside confirm that the expected behavior was my result?

Chad Wood

unread,
Apr 5, 2023, 6:28:55 PM4/5/23
to Google Ads API and AdWords API Forum
I guess there is this bug I brought up:

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.


With that though, the bug occurred client-side, on my workstation. It resulted in a malformed request, as each path in the field mask was prefixed with "update."
Is this the error you're referring to?

Google Ads API Forum Advisor

unread,
Apr 10, 2023, 7:30:39 AM4/10/23
to chadwo...@gmail.com, adwor...@googlegroups.com

Hi Chad,

Thank you for the reply.

Kindly note that we asked for the complete logs (request and response with request-id) to be sure that the ads you are updating are indeed ImageAd or other types that are not supported through the Google Ads API, as the ad that you have provided is reducted and there are other types of ads that are supported in updating. However, if the ad that you are updating is indeed an ImageAd, then I'm afraid that updating this is indeed not supported with the AdService. You may check this documentation for more information.

Moving forward to this "With that though, the bug occurred client-side, on my workstation. It resulted in a malformed request, as each path in the field mask was prefixed with "update."


Is this the error you're referring to?

"

  • Thanks for this update. However, the thing we are referring to is the information I mentioned in my above response.

You may see the links below for the following emphasize words from the above statement:

Best regards,
Reply all
Reply to author
Forward
0 new messages