I have two issues:

I'm calling G-Ads API to bulk remove ads (code)

for error_detail in error_details:             # Retrieve an instance of the google_ads_failure class from the client             failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")             # Parse the string into a google_ads_failure message instance.             # To access class-only methods on the message we retrieve its type.             google_ads_failure = type(failure_message)             failure_object = google_ads_failure.deserialize(error_detail.value)             for error in failure_object.errors:                 # Construct and print a string that details which element in                 # the above ad_group_operations list failed (by index number)                 # as well as the error message and error code.                 print("A partial failure at index "                       f"{error.location.field_path_elements[0].index} occurred "                       f"\nError message: {error.message}\nError code: "                       f"{error.error_code}")                 index_array.append(error.location.field_path_elements[0].index)                 error_array.append({"error_message": error.message, "error_code": error.error_code}) 
  1. I get a partial error
  2. And the code fails to parse it (taken form the official website)

My terminal shows:

Partial failures occurred. Details will be shown below.

Traceback (most recent call last):   File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 426, in get_type     message_class = getattr(type_classes, name)   File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\v8\__init__.py", line 1753, in __getattr__     raise AttributeError(f"unknown type {name!r}.") AttributeError: unknown type 'google_ads_failure'. During handling of the above exception, another exception occurred: Traceback (most recent call last):   File "D:\projects\bowling\src\main.py", line 535, in <module>     main(args.top_id)   File "D:\projects\bowling\src\main.py", line 141, in main     removed_ads_count = remove_disapproved_ads_for_account(account)   File "D:\projects\bowling\src\main.py", line 206, in remove_disapproved_ads_for_account     remove_ads(ad_removal_operations, ads_to_remove_json, account_id)   File "D:\projects\bowling\src\main.py", line 300, in remove_ads     index_array, error_array = _print_results(response_chunk)   File "D:\projects\bowling\src\main.py", line 439, in _print_results     failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")   File "D:\projects\bowling\venv\lib\site-packages\google\ads\googleads\client.py", line 428, in get_type     raise ValueError( ValueError: Specified type 'google_ads_failure' does not exist in Google Ads API v8 

Tag:google-ads-api, google-api, python, google-api-python-client

Only one comment.

  1. SunnyAk

    failure_message = gAdsServiceWrapper.client.get_type("google_ads_failure")

    I think this should be - failure_message = gAdsServiceWrapper.client.get_type("GoogleAdsFailure")

Add a new comment.