【发布时间】:2021-12-21 06:57:45
【问题描述】:
在我的发现 url 被弃用后,我不得不对我的代码进行一些更改,现在我收到了这个错误。
googleapiclient.errors.HttpError:
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{*accountid*}/locations?filter=locationKey.placeId%3{*placeid*}&readMask=paths%3A+%22locations%28name%29%22%0A&alt=json 返回“请求包含无效参数。”。详细信息:“[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'read_mask', 'description': '提供的字段掩码无效'}] }]">
我正在尝试使用这个端点accounts.locations.list
我正在使用:
- python 3.8
- google-api-python-client 2.29.0
我当前的代码如下:
from google.protobuf.field_mask_pb2 import FieldMask
googleAPI = GoogleAPI.auth_with_credentials(client_id=config.GMB_CLIENT_ID,
client_secret=config.GMB_CLIENT_SECRET,
client_refresh_token=config.GMB_REFRESH_TOKEN,
api_name='mybusinessbusinessinformation',
api_version='v1',
discovery_service_url="https://mybusinessbusinessinformation.googleapis.com/$discovery/rest")
field_mask = FieldMask(paths=["locations(name)"])
outputLocation = googleAPI.service.accounts().locations().list(parent="accounts/{*id*}",
filter="locationKey.placeId=" + google_place_id,
readMask=field_mask
).execute()
从错误中,我尝试了很多字段掩码路径,但仍然不知道他们想要什么。 我尝试了 location.name, name, locations.name,locations.location.name 之类的方法,但没有成功。
我也尝试在不使用 FieldMask 类的情况下传递 readMask 参数并传递字符串和同样的问题。
因此,如果有人知道他们想要的 readMask 的格式是什么,那对我来说会很棒!
.
可以帮忙:
https://www.youtube.com/watch?v=T1FUDXRB7Ns
https://developers.google.com/google-ads/api/docs/client-libs/python/field-masks
【问题讨论】:
标签: python google-api google-client