0

I am using ruby and rest-client gem.

I try to communicate with a RESTFUL API.

It's working fine if I use the following:

RestClient.post "http://www.restfulapi.com/students/284433/enroll", {:token => token, :param1 => "56303", :param2 => ""}.to_json, :content_type => :json

but if I decide to use the active resource style:

api = RestClient::Resource.new "http:/www.restfulapi.com"

response = api["/students/284433/enroll"].post  :params => {:token => token, :param1 => "56303", :param2 => ""}

I get an error 412 Precondition Failed (RestClient::PreconditionFailed)

I am not sure what exactly is the difference and why one is working and not the other.

Thank you

Wilson Canda
  • 434
  • 5
  • 19
Regis
  • 375
  • 4
  • 16

1 Answers1

-2

Http status 412 Precondition Failed means that server doesn't meet correct headers in your request. So it seems that you have to set them manually.

May be this can help.

Nick Kugaevsky
  • 2,935
  • 1
  • 18
  • 22