Hello everyone, 

I am working on a Python script to fetch daily campaign data (conversion 
value and cost) from Google Ads using the Google Ads API v17. And I get the 
error :

Error encountered for 2024-01-05: Specified Google Ads API version "v16" 
does not exist. Valid API versions are: "v11", "v10", "v9"

When I use Google Ads API V11, i get the error: 501 GRPC target method cant 
be resolved. 

 I’m currently facing an issue where the search_stream method results in 
the error 501 GRPC target method can't be resolved for certain dates, even 
though I'm using the latest API version that gives in the firstr error.

But as a library I use google-ads==17.0.0 (If i try to change it to lower 
version, my function is not even deploying, Im using cloud function for the 
python script. I use Python 3.10 )

Here is the query I use:

query = f"""
    SELECT
      segments.date,
      metrics.conversions_value,
      metrics.cost_micros
    FROM
      campaign
    WHERE
      segments.date BETWEEN '{start_date_str}' AND '{end_date_str}'
    ORDER BY
      segments.date ASC
"""

And I get the error "501 GRPC target method can't be resolved"


here is the simplified version of my code:

from google.ads.googleads.client import GoogleAdsClient
import gspread

def get_google_ads_client():
    credentials = {
        "developer_token": "my_developer_token",
        "client_id": "my_client_id",
        "client_secret": "my_client_secret",
        "refresh_token": "my_refresh_token",
        "login_customer_id": "my_login_customer_id",
        "use_proto_plus": True  # Using proto-plus for message interface
    }
    return GoogleAdsClient.load_from_dict(credentials, version="v17")

def fetch_google_ads_data(customer_id, start_date, end_date):
    googleads_client = get_google_ads_client()
    query = f"""
        SELECT
          segments.date,
          metrics.conversions_value,
          metrics.cost_micros
        FROM
          campaign
        WHERE
          segments.date BETWEEN '{start_date.strftime('%Y-%m-%d')}' AND 
'{end_date.strftime('%Y-%m-%d')}'
        ORDER BY
          segments.date ASC
    """
    service = googleads_client.get_service("GoogleAdsService", 
version="v17")
    response = service.search_stream(customer_id=customer_id, query=query)

    for batch in response:
        for row in batch.results:
            print(f"Date: {row.segments.date}, Conversion Value: 
{row.metrics.conversions_value}, Cost: {row.metrics.cost_micros}")


Could you please help me how to deal with this problem?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/3ec84d0e-affa-4f94-8cc3-ff2a4fe6fe3an%40googlegroups.com.
  • 50... Unica Analytics
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to