添加客户时,如何解决“ address.country”的无效枚举值?

时间:2019-01-24 11:14:33

标签: square

我正在将方形api和golang集成到我的软件中。但是当我使用下面的json对象发送添加客户请求时出现问题

function Stop-Processes {
    param(
        [parameter(Mandatory=$true)] $processName,
                                     $timeout = 5
    )
    [System.Diagnostics.Process[]]$processList = Get-Process $processName -ErrorAction SilentlyContinue

    ForEach ($Process in $processList) {
        # Try gracefully first
        $Process.CloseMainWindow() | Out-Null
    }

    # Check the 'HasExited' property for each process
    for ($i = 0 ; $i -le $timeout; $i++) {
        $AllHaveExited = $True
        $processList | ForEach-Object {
            If (-NOT $_.HasExited) {
                $AllHaveExited = $False
            }                    
        }
        If ($AllHaveExited -eq $true){
            Return
        }
        Start-Sleep 1
    }
    # If graceful close has failed, loop through 'Stop-Process'
    $processList | ForEach-Object {
        If (Get-Process -ID $_.ID -ErrorAction SilentlyContinue) {
            Stop-Process -Id $_.ID -Force -Verbose
        }
    }
}

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

{
  "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" } ] } 国家(见链接https://docs.connect.squareup.com/)时遇到此错误。我该如何解决这个错误?

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

1 个答案:

答案 0 :(得分:1)

根据他们的文档,您应该以{{1​​}}格式指定国家/地区。

参考文档

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

您也可以从https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

中找到更多信息。