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 6149751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:30:23+00:00 2026-05-23T19:30:23+00:00

The following is the API call to a remote service that executes successfully when

  • 0

The following is the API call to a remote service that executes successfully when I use with HTTParty.

require 'httparty'

class TheAPI
  include HTTParty
  base_uri 'https://someapp.com'
  # headers  "Content-Type" => "application/json"

  def self.create_job
    post( '/jobs.json', :query => {:apikey => "kOrROwbVPNC34VZYhbET", :job => {:method => "PUT", :at => '2012-01-31T18:36:21', :uri => "http://kasko.com"}})
  end
end

puts TheAPI.create_job

But when I try to make the same call using Faraday, I get this unknown error:

require 'faraday_stack'

conn = Faraday.new 'https://someapp.com', ssl: {verify: false} do |builder|
  builder.use   FaradayStack::ResponseJSON,     content_type: 'application/json'
  builder.use   Faraday::Response::Logger#,      Logger.new('faraday.log')
  # builder.use FaradayStack::FollowRedirects,  limit: 3
  builder.use Faraday::Response::RaiseError   # raise exceptions on 40x, 50x responses
  builder.use   Faraday::Adapter::NetHttp
end

# conn.headers[:user_agent] = 'MyLib v1.2'

resp = conn.post "jobs.json", {:apikey => "kOrROwbVPNC34VZYhbET", :job => {:method => "PUT", :at => '2012-01-31T18:36:21', :uri => "http://kasko.com"}}
puts resp

The error raised is:

NoMethodError: undefined method ‘bytesize’ for #<Hash:0x000001011ab8f8>

method send_request_with_body   in http.rb at line 1735
method exec in http.rb at line 1724
method transport_request    in http.rb at line 1189
method request  in http.rb at line 1177
method block in request in http.rb at line 1170
method start    in http.rb at line 627
method request  in http.rb at line 1168
method call in net_http.rb at line 51
method call in response.rb at line 8
method call in response.rb at line 8
method call in logger.rb at line 20
method call in response.rb at line 8
method run_request  in connection.rb at line 203
method post in connection.rb at line 90
method <main>   in test.rb at line 33
  • 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-05-23T19:30:23+00:00Added an answer on May 23, 2026 at 7:30 pm

    It looks like you’re using mislav’s recent blog post about Faraday for a code sample. You’ll notice that in his example, the code you used is only being used for a GET request, not a POST request. When he made a POST request earlier in the page, he set a specific Faraday::Request type.

    Based on the discussion at github, moment requires that you post JSON data, so you need to use this:

    builder.use Faraday::Request::JSON
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that one can call the following API to hibernate the system: SetSuspendState(TRUE,
Let us pick the following Win API call as an example: BOOL MessageBeep(UINT uType);
I'm looking at the following API: http://wiki.github.com/soundcloud/api/oembed-api The example they give is Call: http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=json
I had the following HTML page rendering to use the Google Maps API. This
I'm trying to convert the following NSString api call to a NSURL object: http://beta.com/api/token=
I am retrieving the messaging inbox with the following graph api call: https://graph.facebook.com/me/inbox?access_token=... It
Most of the applications I've seen that use TCP, do roughly the following to
Facebook document that you need to do the following for canvas login Include facebook
I have the following restful api ajax call: $.ajax({ type: POST, url: https://website.com/a/login, data:
i have the following basic script to make an api call to vimeo and

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.