首页 > 解决方案 > 添加客户时如何解决“address.country”的“not a valid enum value”?

问题描述

我在我的软件中集成了 square api 和 golang。但是当我使用以下 json 对象发送添加客户请求时出现问题

{
  "given_name": "Sand Box Customer",
  "family_name": "This is a sandbox Family",
  "email_address": "sandbox@gmail.com",
  "address": {
    "address_line_1": "500 Electric Ave",
    "address_line_2": "Suite 600",
    "locality": "New York",
    "administrative_district_level_1": "NY",
    "postal_code": "10003",
    "country": "Australia"
  },
  "phone_number": "1-212-555-4240",
  "reference_id": "YOUR_REFERENCE_ID",
  "note": "a customer"
}

作为回应,它给我一个错误:-

{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_ENUM_VALUE",
      "detail": "`Australia` is not a valid enum value for `address.country`.",
      "field": "address.country"
    }
  ]
}

为什么我在支持该Australia国家/地区时遇到此错误,请参见链接https://docs.connect.squareup.com/。我该如何解决这个错误?

文档链接:- https://docs.connect.squareup.com/get-started

标签: square

解决方案


根据他们的文档,您应该以/ISO_3166-1_alpha-2格式指定国家/地区。

参考文档

https://docs.connect.squareup.com/api/connect/v2#type-location

您也可以从这里找到更多信息 https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2


推荐阅读