英文:
My Business API: "Provided service type ID is not among those supported by the business's categories."
问题
我正在尝试使用validateOnly
设置为true
来为某个位置添加一些新的服务类型。
但是我得到的响应是:"提供的服务类型ID不在商家类别支持的范围内。"
我已经尝试了不同的serviceId
类型,例如:
gcid:parking_garage
gcid:parking_lot
gcid:parking_lot_for_bicycles
gcid:parking_lot_for_motorcycle
但都没有成功。
完整的错误消息如下:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "service_items[0].structured_service_item.service_type_id",
"description": "提供的服务类型ID不在商家类别支持的范围内。"
}
]
}
]
}
}
我正在使用官方的PHP API客户端和提供的服务API,可以在这里找到:
https://github.com/googleapis/google-api-php-client-services
官方API参考文档:
- https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations/patch?hl=zh-cn
- https://developers.google.com/my-business/content/services?hl=zh-cn
有什么提示吗?
英文:
I am trying to patch a location with some new service types and I am using validateOnly
set to true
.
But the response I am getting is: "Provided service type ID is not among those supported by the business's categories."
I have been testing with different serviceId
types such as:
gcid:parking_garage
gcid:parking_lot
gcid:parking_lot_for_bicycles
gcid:parking_lot_for_motorcycle
but to no avail.
Full error message is:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "service_items[0].structured_service_item.service_type_id",
"description": "Provided service type ID is not among those supported by the business's categories."
}
]
}
]
}
}
I am using the official PHP API client + service APIs as provided here:
https://github.com/googleapis/google-api-php-client-services
Official API reference:
- https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations/patch?hl=en
- https://developers.google.com/my-business/content/services?hl=en
Any tips?
答案1
得分: 1
你误解了文档。获取类别的端点将显示每个类别的可用服务ID,如果您请求完整的CategoryView(https://developers.google.com/my-business/reference/businessinformation/rest/v1/CategoryView)。
要检查给定类别的可用服务,一个不那么繁琐的方法是通过GBP UI将它们添加到测试位置,然后执行一个location get请求,并将readMask设置为serviceItems,以检查该位置的serviceItems数组的样式。
由OP添加:
对于那些对location
对象中的location->categories->primaryCategory->serviceTypes
(也适用于->additionalCategories[x]
)和location->serviceItems
之间的差异感到困惑的人,以下是一些说明:
location->categories->primaryCategory->serviceTypes
似乎是只读的- 您只需要对
location->categories->primaryCategory
(->additionalCategories[x]
也是如此)进行修补,格式类似于categories/gcid:wellness_center
- 您只需要对
location->serviceItems
是可以直接更新(修补)的- 格式类似于
job_type_id:swimming
用于structuredServiceItem
- 任何字符串都可以用于
freeFormServiceItem
。
- 格式类似于
英文:
You misunderstood that documentation. The endpoint to get the categories will show you the available serviceIds per category if you request the FULL CategoryView (https://developers.google.com/my-business/reference/businessinformation/rest/v1/CategoryView).
To inspect available services for the given categories, a less cumbersome approach is to add them to a test location via the GBP UI and then execute a location get request and readMask set to serviceItems to inspect what the serviceItems array looks like for that location.
Added by the OP:
For anyone wondering about location
object difference between location->categories->primaryCategory->serviceTypes
(also for ->additionalCategories[x]
) and location->serviceItems
some info to clarify:
location->categories->primaryCategory->serviceTypes
seems to bereadonly
- and you just need to patch
location->categories->primaryCategory
(->additionalCategories[x]
), format is similar tocategories/gcid:wellness_center
- and you just need to patch
location->serviceItems
are meant to be updated (patched) directly- format is similar to
job_type_id:swimming
forstructuredServiceItem
- and any string for
freeFormServiceItem
.
- format is similar to
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论