我使用的是ruby和rest-client gem。
我尝试使用RESTFUL API进行通信。
如果我使用下面的代码,它工作得很好:
RestClient.post "http://www.restfulapi.com/students/284433/enroll", {:token => token, :param1 => "56303", :param2 => ""}.to_json, :content_type => :json但如果我决定使用活动资源样式:
api = RestClient::Resource.new "http:/www.restfulapi.com"
response = api["/students/284433/enroll"].post :params => {:token => token, :param1 => "56303", :param2 => ""}我收到错误412前置条件失败(RestClient::Precondition )
我不确定到底有什么不同,以及为什么一个能工作而另一个不能工作。
谢谢
发布于 2012-09-07 06:18:19
Http status 412 Precondition Failed意味着服务器没有在你的请求中遇到正确的头。因此,您似乎必须手动设置它们。
这可能会有所帮助。
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
https://stackoverflow.com/questions/12309096
复制相似问题