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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:22:48+00:00 2026-06-17T11:22:48+00:00

I am trying to use net/http to get a response for API call based

  • 0

I am trying to use net/http to get a response for API call based on an old library I dug up https://github.com/jurisgalang/facebook/blob/master/lib/facebook/graph-object.rb#L22

require 'net/http'

API_HOST       = "graph.facebook.com"
API_BASE_URL   = "https://#{API_HOST}"
path           = "/boo"

uri            = URI.parse "#{API_BASE_URL}#{path}"
http           = Net::HTTP.new(uri.host, uri.port)
res            = http.get(uri.request_uri, nil)

The uri ends up as <URI::HTTPS:0x0000010091fc48 URL:https://graph.facebook.com/boo>

This results in

NoMethodError: undefined method `keys’ for nil:NilClass

I assumed it is because dest argument is obsolete: http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-get

So I did it without

res            = http.get(uri.request_uri)

Which results in

NoMethodError: undefined method `empty?’ for

#<URI::HTTPS:0x0000010091fc48 URL:https://graph.facebook.com/boo>

How can one request a response using net/http and http.get?

  • 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-17T11:22:49+00:00Added an answer on June 17, 2026 at 11:22 am

    Just at a very quick glance of the documentation, the second argument to get is a hash, and you’re passing nil, see:

    http.get(uri.request_uri, nil)
    

    Your second attempt should be OK, though I did find that with my setup (ruby 1.9.3 and MacPorts’ openssl library) that Net::HTTP was rejecting Facebook’s ssl certificate (I was getting “Connection reset by peer”. The following code snippet worked for me:

    require 'net/http'
    
    API_HOST       = "graph.facebook.com"
    API_BASE_URL   = "https://#{API_HOST}"
    path           = "/boo"
    
    uri            = URI.parse "#{API_BASE_URL}#{path}"
    http           = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl   = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    res            = http.get(uri.request_uri)
    puts res.body
    

    Note that I’m not verifying the SSL certificate, which is a potential security problem. As a proof of concept, however, this snippet worked for me – so hopefully this will give you a good data point in your debugging effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Net::HTTP.get_print in a rails app to get the response from
I'm trying to use this article: https://github.com/Licensario/licensario-rest-protocol/blob/master/rest-api.md#feature-usage so I wrote: ## get request feature_allocation_req
I'm trying to use the Lizzy library ( http://lizzy.sourceforge.net/ ) to do some playlist
I'm trying to use net/http to interact w/ the Yahoo Placemaker API but I
I'm trying to use a java.net.HttpURLConnection to make an HTTP request to a server.
I am trying to use the tranlsation webservice from MyMemory: http://mymemory.translated.net/doc/spec.php Unfortunately, Zend_Soap_Client does
alt text http://www.freeimagehosting.net/image.php?a55fa98f01.jpg Hi I am trying to use a HTML select box with
I am trying to use a Web Service generated on Apache Axis: http://webservicepilot.tecdoc.net/pegasus-2-0/wsdl/TecdocToCatWL VehicleManufacturers3Request
Possible Duplicate: Uploadify: show error message from HTTP response I am trying to get
i'm trying to use curl with jruby to get some response times for webpages/files.

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.