在我的发现 url 被弃用后,我必须对我的代码进行一些更改,现在我收到此错误。
googleapiclient.errors.HttpError:<请求https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{*accountid*}/locations?filter=locationKey.placeId%3{*placeid*}&readMask=paths%3A+时出现 HttpError 400 %22locations%28name%29%22%0A&alt=json返回“请求包含无效参数。”。详细信息:“[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'read_mask', 'description': '提供的字段掩码无效'}] }]">
我正在尝试使用这个端点accounts.locations.list
我在用着 :
我当前的代码如下所示:
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()
Run Code Online (Sandbox Code Playgroud)
从错误中,我尝试了很多fieldmask路径,但仍然不知道他们想要什么。我尝试过诸如location.name、name、locations.name、locations.location.name 等操作,但没有成功。
我还尝试传递 readMask 参数,而不使用 FieldMask 类来传递字符串和相同的问题。
因此,如果有人知道他们想要的 readMask 的格式是什么,这对我来说会很棒!
。
可以帮助:
https://www.youtube.com/watch?v=T1FUDXRB7Ns
https://developers.google.com/google-ads/api/docs/client-libs/python/field-masks