Pulling Data from Resource Fields in Google API Beta Reports

46 views
Skip to first unread message

Drew Lauck

unread,
Jan 9, 2020, 1:46:15 PM1/9/20
to AdWords API and Google Ads API Forum
Afternoon,

I'm currently having trouble pulling data from the ad_group_ad report (https://developers.google.com/google-ads/api/fields/v2/ad_group_ad). I need to pull the ad_group_ad.ad.final_urls along with all of the headlines.

I'm using this query:

    query = ('SELECT campaign.idad_group.idad_group.name, ad_group_ad.ad.final_urls '
            'FROM ad_group_ad'
            )

and using this print() to test and see what data I get:

            print('Ad group with ID %d and name "%s" was found in campaign '
                  'with ID %d and the Final URL is "%s".'
                  % (row.ad_group.id.value, row.ad_group.name.value,
                     row.campaign.id.value, row.ad_group_ad.ad.final_urls.value))


I keep getting this error: 

Traceback (most recent call last):
  File "test_ad_group_ad.py", line 67, in <module>
    main(google_ads_client, args.customer_id, _DEFAULT_PAGE_SIZE)
  File "test_ad_group_ad.py", line 42, in main
    row.campaign.id.value, row.ad_group_ad.ad.final_urls.value))
AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute 'value' 

and I don't know why. Any help would be appreciated.

Drew Lauck

unread,
Jan 9, 2020, 2:50:27 PM1/9/20
to AdWords API and Google Ads API Forum
I removed .value from row.ad_group_ad.ad.final_urls.value and the script works but the data comes out as [value: "https://example.com/example]. Is there a way to get just the url without the value and brackets?

Google Ads API Forum Advisor Prod

unread,
Jan 9, 2020, 5:27:44 PM1/9/20
to drewl...@gmail.com, adwor...@googlegroups.com

Hi Silvia,

Thanks for reaching out. The final_urls is a list with String value. This is the reason as to why it is not possible to use the value field directly.You could use row.ad_group_ad.ad.final_urls[0].value to access the first url. Please let me know if you have any further concerns.

Thanks and regards,
Xiaoming, Google Ads API Team


 

ref:_00D1U1174p._5001USw0cp:ref
Reply all
Reply to author
Forward
0 new messages