My Business Business Information API字段掩码错误排查求助
解决Google My Business Business Information API的read_mask参数错误问题
问题根源分析
你遇到的两个400错误均因read_mask参数使用不符合API规则:
- 第一个错误是遗漏必填的
read_mask参数,仅使用fields参数无法满足API要求; - 第二个错误是
read_mask格式错误——你使用了locations.name这种嵌套路径,但该参数需指定Location资源的顶级字段名,而非数组嵌套结构。
正确参数用法
Google My Business的accounts.locations.list接口要求read_mask明确指定需返回的Location资源字段,字段名直接使用Location对象的顶级属性(如name、title、address等),多字段用逗号分隔。
示例1:仅获取门店name
请求URL:
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?read_mask=name
示例2:获取门店name和title
请求URL:
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?read_mask=name,title
示例3:结合fields参数过滤响应结构
若需仅返回响应中的locations数组(过滤冗余元数据),可同时使用fields和read_mask:
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?fields=locations&read_mask=name,title
额外注意事项
- 确保在OAuth Playground中已授权正确的API权限范围:
https://www.googleapis.com/auth/business.manage,权限不足会导致后续访问错误; - 替换URL中的
{accountId}为实际账号ID,注意移除大括号。
内容的提问来源于stack exchange,提问作者Hyzac
相关产品推荐
相关产品推荐

