Getting Audiences From API Issues

95 views
Skip to first unread message

João Pedro

unread,
May 3, 2022, 4:38:08 PM5/3/22
to Google Ads API and AdWords API Forum
Hello!

I'm having some issues when i try to get the audiences data from API.
The code I'm using is:

from google.ads.googleads.client import GoogleAdsClient

client_g = GoogleAdsClient.load_from_storage(version="v9") 
ga_service = client_g.get_service("GoogleAdsService")
client_customer_id = 'my great ID'

query = """
       SELECT
          audience.id,
          audience.resource_name,
          audience.name,
          audience.status,
          audience.description,
          audience.dimensions,
          audience.exclusion_dimension
        FROM audience
    """

search_request = client_g.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = client_customer_id
search_request.query = query
stream = ga_service.search_stream(search_request)

ERROR: Request made:, Host: googleads.googleapis.com, Method: /google.ads.googleads.v9.services.GoogleAdsService/SearchStream,, IsFault: True, FaultMessage: Unrecognized fields in the query: 'audience.exclusion_dimension', 'audience.status', 'audience.dimensions', 'audience.description', 'audience.resource_name', 'audience.id', 'audience.name'.


And the example of the code here:

What I don't understand is: if I've found all this in the documentation, it supposed to work, not fail. And I tried to run with 'campaign', 'adgroup' instead of 'audience' and it worked. What should I do?

Google Ads API Forum Advisor

unread,
May 4, 2022, 9:50:39 AM5/4/22
to joao....@nagro.app, adwor...@googlegroups.com
Hi João,

Thank you for reaching out to the Google Ads API Forum. 

With regard to your concern, I can see that you are using the V9 version which is not supported to the report that you are currently using. With this, I suggest upgrading to the newest version as the report you are using is supported on the newest version. For more information please check this document.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


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