googleads / google-ads-python

Google Ads API Client Library for Python
Apache License 2.0
526 stars 480 forks source link

Request to keyword_plan_idea_service.generate_keyword_historical_metrics causes AttributeError #816

Closed MarkusZschochBenuta closed 1 year ago

MarkusZschochBenuta commented 1 year ago

Describe the bug: I am trying to get historical data by calling KeywordPlanIdeaService.GenerateKeywordHistoricalMetrics as described in the Generate Historical Metrics Guide.

When running the script, I get a AttributeError.

Steps to Reproduce:

  1. Install virtual environment.
  2. Install dependencies (see below).
  3. Set up script from guide, using client and customer_id.
  4. Run the script.

Expected behavior: Get historical metrics.

Client library version and API version: Client library version: Google Ads API version: Python version: Python 3.11.0

cachetools==5.3.1 certifi==2023.7.22 charset-normalizer==3.2.0 google-ads==22.1.0 google-api-core==2.11.1 google-api-python-client==2.98.0 google-auth==2.23.0 google-auth-httplib2==0.1.1 google-auth-oauthlib==1.1.0 googleapis-common-protos==1.60.0 grpcio==1.59.2 grpcio-status==1.59.2 httplib2==0.22.0 idna==3.4 numpy==1.25.2 oauth2client==4.1.3 oauthlib==3.2.2 pandas==2.1.0 proto-plus==1.22.3 protobuf==4.24.3 pyasn1==0.5.0 pyasn1-modules==0.3.0 pyparsing==3.1.1 python-dateutil==2.8.2 python-decouple==3.8 pytz==2023.3.post1 PyYAML==6.0.1 requests==2.31.0 requests-oauthlib==1.3.1 rsa==4.9 six==1.16.0 tzdata==2023.3 uritemplate==4.1.1 urllib3==1.26.16 Request/Response Logs: [2023-11-08 12:57:21,119 - DEBUG] Making request: POST https://accounts.google.com/o/oauth2/token [2023-11-08 12:57:21,186 - DEBUG] Starting new HTTPS connection (1): accounts.google.com:443 [2023-11-08 12:57:21,411 - DEBUG] https://accounts.google.com:443 "POST /o/oauth2/token HTTP/1.1" 200 None Traceback (most recent call last): File "keywords.py", line 116, in main() File "keywords.py", line 111, in main generate_historical_metrics(client, customer_id) File "keywords.py", line 18, in generate_historical_metrics request.keywords = ["mars cruise", "cheap cruise", "jupiter cruise"] ^^^^^^^^^^^^^^^^ AttributeError: Assignment not allowed to message, map, or repeated field "keywords" in protocol message object.

Anything else we should know about your project / environment:

BenRKarl commented 1 year ago

To run the examples as-is, you'll need to set use_proto_plus to True, otherwise you will run into syntax errors like this. For more details on the differences between proto-plus messages and normal protobuf messages see this guide