Hi team,

I am using Google Ads API to get report from Google Ads. I am running the 
same code on GCP but when I try to run it locally I get an error. The error 
says Invalid Customer ID. I am sure everything is correct, I am using 
Python 3.12 version and using latest version of Google Ads API. But I get 
the same error every time. I am sending my code script and error message: 

def get_campaign(date_start, date_end, customer_id):
ca_query = f"""
SELECT
campaign.id, 
campaign.name,
customer.id,
customer.descriptive_name,
customer.currency_code,
segments.date,
segments.product_brand,
segments.product_title,
segments.product_item_id,
metrics.clicks, 
metrics.cost_micros, 
metrics.impressions
metrics.conversions,
metrics.conversion_value,
metrics.revenue_micros,
metrics.gross_profit_micros,
metrics.product_category_level1,
metrics.product_category_level2,
metrics.product_category_level3,
metrics.product_category_level4,
metrics.product_category_level5

FROM campaign
WHERE 
segments.date BETWEEN {"'" + date_start + "'"} AND {"'" + date_end + "'"}"""

search_request = gads_client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = f"{customer_id}"
search_request.query = ca_query
gads_stream = gads_ga_service.search_stream(search_request)
print("Google Ads Client OK")

data_list = []
for batch in gads_stream:
for row in batch.results:
data_dict = {
'campaign_id': row.campaign.id,
'campaign.name': row.campaign.name,
'customer_id': row.customer.id,
'customer_name': row.customer.descriptive_name,
'product_brand': row.segments.product_brand,
'product_title': row.segments.product_title,
'product_item_id': row.segments.product_item_id,
'currency_code': row.customer.currency_code,
'ad_group_id': row.ad_group.id,
'ad_group_name': row.ad_group.name,
'date': row.segments.date,
'clicks': row.metrics.clicks,
'cost_micros': row.metrics.cost_micros,
'impressions': row.metrics.impressions,
'conversions': row.metrics.conversions,
'conversion_value': row.metrics.conversion_value,
'revenue_micros': row.metrics.revenue_micros,
'gross_profit_micros': row.metrics.gross_profit_micros,
'product_category_level1': row.metrics.product_category_level1,
'product_category_level2': row.metrics.product_category_level2,
'product_category_level3': row.metrics.product_category_level3,
'product_category_level4': row.metrics.product_category_level4,
'product_category_level5': row.metrics.product_category_level5

}
data_list.append(data_dict)

df = pd.DataFrame(data_list)
print("Dataframe read is OK!")
try:
df[['cost_micros']] = df[['cost_micros']] / 1000000

df['date'] = df['date'].astype('datetime64[ns]')
except:
print("Columns has not found")

return df

I forward to API my customer_id like below:

"2852897198"

Can you help me about this ? 


Best,
Bugra

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 visit 
https://groups.google.com/d/msgid/adwords-api/e1b159b1-9033-494f-af6f-e1e090b91ec5n%40googlegroups.com.

Reply via email to