You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Business Profile API调用accounts.locations.list出现read_mask无效400错误

你遇到的报错是read_mask参数的传值格式和字段路径不符合接口要求,修正方法如下:

错误原因

  1. 该接口不需要传入FieldMask类实例,直接传入逗号分隔的字段名字符串即可,你传入的FieldMask对象会被序列化为包含paths结构的内容,和接口要求的read_mask格式不匹配。
  2. 你使用的locations(name)这类路径写法错误,accounts.locations.list接口的readMask只需要指定单条Location资源下的字段名,不需要额外套外层的locations结构。

正确代码示例

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")

outputLocation = googleAPI.service.accounts().locations().list(
    parent="accounts/{*id*}",
    filter=f"locationKey.placeId={google_place_id}",
    # 直接写需要返回的Location资源字段,多个字段用英文逗号分隔
    readMask="name"
).execute()

如果需要同时返回多个字段,比如location的名称、地址、营业时间,直接按如下格式写即可:
readMask="name,title,address,regularHours"

内容的提问来源于stack exchange,提问作者ag7-alexis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 10:00:05