Ruby rest客户端错误412

Ruby rest客户端错误412,ruby,rest-client,Ruby,Rest Client,我正在使用ruby和rest客户端gem 我尝试与RESTFUL API通信 如果我使用以下选项,则工作正常: RestClient.post "http://www.restfulapi.com/students/284433/enroll", {:token => token, :param1 => "56303", :param2 => ""}.to_json, :content_type => :json 但如果我决定使用活动资源样式: api = RestCl

我正在使用ruby和rest客户端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::PremissionFailed)

我不知道到底有什么区别,为什么一个有效而另一个无效


谢谢

Http status
412前置条件失败
表示服务器未满足您请求中的正确头。因此,似乎您必须手动设置它们

也许这会有帮助

  • rfc2616-
  • 剩余客户文件-