Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:45:59+00:00 2026-06-10T22:45:59+00:00

I am using ruby and rest-client gem. I try to communicate with a RESTFUL

  • 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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:46:01+00:00Added an answer on June 10, 2026 at 10:46 pm

    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.

    • rfc2616 – http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
    • rest_client docs – http://rubydoc.info/gems/rest-client/1.6.7/frames
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Rest-client gem in ruby.My code is as follows.., require 'rest_client' puts RestClient.get
I need to post to a REST resource by using ruby rest-client gem. The
I am writing some tests in Ruby using RestClient. The test is working fine
I'm writing a Ruby interface to Fluidinfo , using the rest-client gem as a
I try to learn REST in Ruby using Twitter API. According https://dev.twitter.com/docs/api/1/get/trends I have
I am using the ruby gem rest-client with rest-client-components . Rest-client-components enables request logging
I wonder what the REST API clients are available for using from Ruby (not
I am trying to query an api through JSON / REST using Ruby. require
I'm using the Ruby REST API for Redmine (here: http://www.redmine.org/projects/redmine/wiki/Rest_api_with_ruby ). I need to
I'm interested in setting my own user agent when using the ruby RestClient gem.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.