Posts tagged with google-api

I am migrating our API ingestion from googleads to google-ads in python and I noticed that the campaign resource only returns entities that have status "ENABLED". In the googleads version, it returns all entities by default when you request for it.

I tried modifying the GAQL to include filtering like where campaign.status != 'ENABLED' and I get no results back from the API.

Is there a way to get entities with all status like "PAUSED", "REMOVED" etc? Also, is there a place to run the GAQL in the web UI? (They have the GAQL validator but it doesn't let me run it)

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 

I'm querying Google Ads Api via google/apiclient:2.0 in PHP using this GAQL:

SELECT asset.final_urls, asset.name, asset.type, asset.id FROM ad_group_ad_asset_view WHERE segments.date = '$date' 

But all the type YOUTUBE_VIDEO result had an empty asset.name. When I query from the hub, the Asset name is not empty. What should I do to get the right asset name for YOUTUBE_VIDEO?

I made a script using Google Ads API to get reports from Google Ads. But the refresh token expires every 7 days. I found out that it happens because the app should be published (have publishing status "In production" instead of "Testing"). So I did it. But then the Verification status changed to "Needs verification". An option "Prepare for verification" appears

If I try to "Prepare for verification" than it requires to authorize domain of my app. So this is an option for cases when someone wants to make an app for multiple users.

But it's not my case, I just get reports from my own Google Ads account. I found out that probably the problem could be solved if I change User type of my app from "External" to "Internal". But it seems that it only an option for Google Workspace users.

But as I see on their site it is not free.

I am sure there should be some free option how to do this. Everything else works fine, the problem is just the refresh token expiration. Maybe I missed something, please help.