我正在使用 ruby 1.9.3 和 httparty gem 发出以下 API GET 请求:
uri= HTTParty.post("www.surveys.com/api/v2/contacts",
:basic_auth => auth,
:headers => { 'ContentType' => 'application/json' },
:body => {
"custom_test" => test,
"name" => firstname,
"email" => emailaddress
}
)
变量auth
、test
、firstname
和emailaddress
是有效的。这是我从我的请求中收到的回复:
{
"code": "invalid_json",
"description": "Request sent with Content-Type: application/json but was unable to decode request body as valid json.",
"success": false
}
500
#<Net::HTTPInternalServerError:0x007fe4eb98bde0>
我发布此 JSON 请求的方式有什么问题?
编辑:可能值得注意的是,API 允许您为联系人定义自定义属性,因此正文中的“custom_test”属性。