googleads/google-ads-python

Get historical metrics: protocol message object error

anthonyrka opened this issue · 1 comments

https://github.com/googleads/google-ads-python/blob/310a10b18f3ce91fc5c885f63ba090641972fbe1/examples/planning/generate_historical_metrics.py#L50C25-L50C72

Returns the following error:

AttributeError: Assignment not allowed to message, map, or repeated field "keywords" in protocol message object.

The correct way to set repeated fields in Protocol Buffers is to use the .append() method for singular values and .extend() for multiple values.
This:

request.keywords = ["mars cruise", "cheap cruise", "jupiter cruise"]

should be:

request.keywords.extend(["mars cruise", "cheap cruise", "jupiter cruise"])
```

@anthonyrka I'm assuming you have the configuration parameter use_proto_plus set to False, is that the case? Note that the examples are all written with this flag set to True, so they will likely not function properly when set to false. See this guide for details on the interface differences between proto-plus and regular protobuf messages.