我的商业API:”提供的服务类型ID不在商家类别支持的范围内。”

huangapple go评论79阅读模式
英文:

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参考文档:

有什么提示吗?

英文:

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:

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 be readonly
    • and you just need to patch location->categories->primaryCategory (->additionalCategories[x]), format is similar to categories/gcid:wellness_center
  • location->serviceItems are meant to be updated (patched) directly
    • format is similar to job_type_id:swimming for structuredServiceItem
    • and any string for freeFormServiceItem.

huangapple
  • 本文由 发表于 2023年8月8日 21:57:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76860263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定