Resource Exhausted Using get_geo_target_constant

98 views
Skip to first unread message

Scott Vaillancourt

unread,
Oct 27, 2020, 7:12:08 PM10/27/20
to AdWords API and Google Ads API Forum
I running a report using the search_stream method within GoogleAdsService. One of the fields I'm pulling back is geo_target_metro, which returns resource name such as 'geoTargetConstants/200819'. I'm trying to get the name associated with each location. However, when I use get_geo_target_constant(Resource Name).name, I get an error saying I've exhausted my resources, which I assume are the 1000 gets. (Note: I can run the exact same code without calling get_geo_target_constant and not have any problems. How can I get the name associated with geo_target_metro without running out of resources? Thanks.

Google Ads API Forum Advisor Prod

unread,
Oct 28, 2020, 2:15:04 AM10/28/20
to sc...@lionhurst.com, adwor...@googlegroups.com
Hi Scott,

Thank you for reaching our to out API support team.

The GoogleAdsService (Search and SearchStream) is also subject to limits which you can find out more via this guide. Regardless of access level, customers would indeed only be able to make up to 1,000 get requests per day.

For the error you are encountering, could you provide more details on how exactly you are encountering this? Could you provide your customer ID and the complete request and response logs containing the error message you received? 

You may send the requested information using the Reply privately to author option.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q275C0l:ref

Scott Vaillancourt

unread,
Oct 28, 2020, 10:18:50 AM10/28/20
to AdWords API and Google Ads API Forum
Hi Peter,

Thanks for the info. I don't have adequate permissions to reply to author, so I'll send you what I can via this post. Shown below is the code I'm using to execute the request. The error message I get back is '429 Resource has been exhausted (e.g., check quota)'. I'm pretty certain the limit that's being exceeded is because of the call to get_geo_target_constant. If I run the code without this it works fine. I think what I'm trying to figure out is how to resolve resource names without a 'get' call. This applies to other items such as campaign_budget. Hope this helps. Thanks.

Scott

***************************************************************************************************************
from google.ads.google_ads.client import GoogleAdsClient

client = GoogleAdsClient.load_from_storage('/users/google-ads.yaml')
gas = client.get_service('GoogleAdsService', version='v5')

query = '''
    SELECT
        campaign.name,
        campaign.advertising_channel_type,
        campaign.campaign_budget,
        metrics.impressions,
        metrics.clicks,
        metrics.cost_micros,
        segments.geo_target_metro,
        segments.date
    FROM geographic_view
    WHERE
        segments.date BETWEEN "2020-10-01" AND "2020-10-20"
    ORDER BY campaign.name ASC
    LIMIT 1000'''

cid = <CUSTOMER ID>
resp = gas.search_stream(cid, query)
report = []

for batch in resp:
    for row in batch.results:
        cdate = row.segments.date
        camp = row.campaign.name
        metro = gts.get_geo_target_constant(row.segments.geo_target_metro).name
        impr = row.metrics.impressions
        clicks = row.metrics.clicks
        cost = row.metrics.cost_micros / 1000000
        channel = row.campaign.advertising_channel_type
        budget = row.campaign.campaign_budget
        report.append([cdate, camp, metro, impr, clicks, cost, channel, budget])
***************************************************************************************************************


Google Ads API Forum Advisor Prod

unread,
Oct 29, 2020, 3:40:18 AM10/29/20
to sc...@lionhurst.com, adwor...@googlegroups.com
Hi Scott,

Thank you so much for sending these.

However, since you are unable to use the described reply option, please send all the relevant details (customer ID, complete request and response logs) directly to our googleadsa...@google.com alias instead, so we can continue the discussion in private.
Reply all
Reply to author
Forward
0 new messages