我收到的400看起来是有效的json(通过JSONLint验证)。 Square connect与描述字段不同:
{
"requests": [
{
"method": "POST",
"relative_path": "/v1/me/items",
"access_token": "xxx-xxxxxxxxxxxxxxxxxx",
"body": {
"name": "9001 Donald Duck",
"description": "’a’",
"abbreviation": "test",
"visibility": "PRIVATE",
"available_online": false,
"variations": [
{
"name": "credit card payment",
"pricing_type": "FIXED_PRICING",
"price_money": {
"currency_code": "USD",
"amount": "-8735"
},
"sku": "7fa314q7_B9001_0",
"track_inventory": true
}
]
}
}
]
}
这些字符也会出现同样的问题:“ ”
当我尝试使用仪表板键入这些字符时,我得到“我们很抱歉,但出了点问题。”所以应该避免这些字符。
是否有无效字符列表?此外,如果您回发导致失败的json对象部分,将会很有帮助。如果在Square结束时知道原因,那么浪费时间浪费时间似乎很愚蠢,不是吗?
答案 0 :(得分:0)
'我有时也收到400.request是续订,参数在下面。
def refresh_access_token!
....
begin
#renew api
response = oauth_connection.post SQUARE_RENEW_URL do |req|
req.headers['Authorization'] = "Client #{SQUARE_CLIENT_SECRET}"
req.headers['Content-Type'] = 'application/json'
req_body = req.body = "{ \"access_token\": \"xxxxx-xxxxxxxxxxx\" }"
end
....
end
def oauth_connection
@oauth_connection ||= Faraday.new(SQUARE_CONNECT_URL) do |conn|
conn.request :url_encoded
conn.request :json
conn.response :json, :content_type => /\bjson$/
conn.adapter Faraday.default_adapter
end
end