0
我很困難搞清楚這一點。這個捲曲命令工作正常:Http協議帖子返回'422'不可處理的實體''
curl -v -k --basic -u"username:password" -XPOST -H"X-API-VERSION:1" -H"Accept:application/json" -H"Content-Type:application/x-www-form-urlencoded" -data'jsonData={"email":"[email protected]"}' https://api.somenetwork.net/coreg/users
但是,httparty總是返回'422'不可處理的實體「'。
這裏是我的代碼:
class CoregBase
include HTTParty
def initialize
self.class.base_uri "https://api.somenetwork.net/coreg"
self.class.basic_auth "username", "password"
self.class.headers({'X-API-VERSION' => '1',
'Accept' => 'application/json'})
end
end
class Users < CoregBase
include HTTParty
def initialize
super
end
def create_co_registration_user
self.class.headers({ 'X-API-VERSION' => '1',
'Accept' => 'application/json',
'Content-Type' => "application/x-www-form-urlencoded"})
options = {
:body => {"email" => "[email protected]"}}
self.class.post('/users', options)
end
end
coreg_user = Users.new
result = coreg_user.create_co_registration_user
pp result
請接受你自己的答案,因此下車的「懸而未決」名單。謝謝! – awendt 2011-09-01 09:18:28