square - 添加客户时如何解决“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/。我该如何解决这个错误?
解决方案
根据他们的文档,您应该以/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
推荐阅读
- php - 如何在 Opensuse 风滚草中安装 PHP8 XDebug?
- amazon-web-services - AWS Dynamo DB:如何在没有 GSI 的情况下进行有效设计
- javascript - Vuelidate匹配/sameAs但忽略大小写敏感?
- flutter - Flutter:InkWell 在 Card 中完全不起作用
- python - 如何在 mac os x 上使用 gunicorn 和 python3.8 而不是 python3.9?
- javascript - 如何在 React 中使用 Toggle 方法切换 CSS 样式
- google-classroom - 获取学生提交的 google 课堂作业的 id
- sql - 使用分隔符连接或合并许多列值并忽略空值 - SQL Server 2016 或更早版本
- python - TypeError:文件必须具有“写入”属性
- javascript - 如何从 React 中的 API 数据制作 3 列行