0

我正在使用 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 Precondition Failed (RestClient::PreconditionFailed)

我不确定到底有什么区别以及为什么一个工作而不是另一个工作。

谢谢

4

1 回答 1

-2

Http 状态412 Precondition Failed意味着服务器在您的请求中不符合正确的标头。因此,您似乎必须手动设置它们。

可能这会有所帮助。

于 2012-09-06T22:18:18.817 回答