AttributeError: 'META'

131 views
Skip to first unread message

Анатолий Копыток

unread,
May 5, 2021, 7:21:08 PM5/5/21
to AdWords API and Google Ads API Forum
Good afternoon. I am a beginner Django Python super master. I face big problems every day, but there is one big problem that I can't solve for more than 2 days. I'm trying to make a project using the google ads api. I have completed all the necessary procedures and can connect to test accounts to receive information and make changes to test accounts. But when trying to port this to django-I ran into problems. My last solution works at 50%. I get the necessary information and immediately get an additional ERROR.

the essence:
in views.py I call a function that connects to a test account to collect statistics for a given keyword. I get statistics, and an error.
I will be glad of any help or hint) thank you!
---------------------------------------------------------------------------------------------
AttributeError at /faq
'META'
Request Method: GET
Django Version: 3.2
Exception Type: AttributeError
Exception Value:
'META'
Exception Location: F:\python\apiserv_website\myvenv\lib\site-packages\proto\message.py, line 605, in __getattr__
Python Executable: F:\python\apiserv_website\myvenv\Scripts\python.exe
Python Version: 3.9.3
Python Path:
['F:\\python\\apiserv_website\\apiserv',
 'C:\\Users\\romar\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
 'C:\\Users\\romar\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
 'C:\\Users\\romar\\AppData\\Local\\Programs\\Python\\Python39\\lib',
 'C:\\Users\\romar\\AppData\\Local\\Programs\\Python\\Python39',
 'F:\\python\\apiserv_website\\myvenv',
 'F:\\python\\apiserv_website\\myvenv\\lib\\site-packages']
Server time: Wed, 05 May 2021 23:13:14 +0000
---------------------------------------------------------------------------------------
views.py  
the code inside the function I'm calling:
---------------------------------------------------------------------------------------
credentials = {
        "developer_token": "hide",
        "refresh_token": "hide",
        "client_id": "hide",
        "client_secret":  "hide" }

    client = GoogleAdsClient.load_from_dict(credentials)

    keyword_texts = ['slippers']
    language_id = "1000"
    location_ids = "1023191"
    customer_id = "4677556196"


    def _map_locations_ids_to_resource_names(client, location_ids):
        """Converts a list of location IDs to resource names.

        Args:
            client: an initialized GoogleAdsClient instance.
            location_ids: a list of location ID strings.

        Returns:
            a list of resource name strings using the given location IDs.
        """
        build_resource_name = client.get_service(
            "GeoTargetConstantService"
        ).geo_target_constant_path
        return [build_resource_name(location_id) for location_id in location_ids]


    keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
    keyword_competition_level_enum = client.get_type(
        "KeywordPlanCompetitionLevelEnum"
    ).KeywordPlanCompetitionLevel
    keyword_plan_network = client.get_type(
        "KeywordPlanNetworkEnum"
    ).KeywordPlanNetwork.GOOGLE_SEARCH_AND_PARTNERS
    language_rn = client.get_service(
        "LanguageConstantService"
    ).language_constant_path(language_id)




    request = client.get_type("GenerateKeywordIdeasRequest")
    request.customer_id = customer_id
    request.language = language_rn
    request.include_adult_keywords = False
    request.keyword_plan_network = keyword_plan_network


    request.keyword_seed.keywords.extend(keyword_texts)


    keyword_ideas = keyword_plan_idea_service.generate_keyword_ideas(
        request=request
    )
    limit = 20
    index = 0
    goog_key_tool = []
    for idea in keyword_ideas:
        competition_value = idea.keyword_idea_metrics.competition.name
        goog_key_tool.append(idea.keyword_idea_metrics.avg_monthly_searches)
        index += 1
        if index == limit:
            break
    print(goog_key_tool)
--------------------------------------------------------------------------------------
error screenshot.png

Google Ads API Forum Advisor Prod

unread,
May 5, 2021, 11:40:31 PM5/5/21
to get4...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for posting your concern.

Our team can only provide support to concerns / issues related to Google Ads API / AdWords API. Since your issue / concern is specific to implementation of Python code, then I would suggest reaching out to the author of the Python client library via this link. The author of the Python client library is more equipped to provide support with the issues / concerns related to the said client library.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


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