我收到了一个400,看起来是有效的json (通过JSONLint验证)。Square connect不喜欢description字段:
{
"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的一端是已知的,不是吗?
发布于 2014-06-25 10:57:01
我有时会收到400,too.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
endhttps://stackoverflow.com/questions/23840527
复制相似问题