I want to request user information from an API using ruby so I'm following this ruby http cheat sheet:
http://augustl.com/blog/2010/ruby_net_http_cheat_sheet/
This is what I'm using so far:
#!/usr/bin/ruby
require "net/http"
require "uri"
uri = URI.parse("https://cirrus.app47.com/api/users/obfuscated_userID")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
request.initialize_http_header({"X-Token" => "obfuscated-TokenString"})
request.initialize_http_header({"Accept" => "application/json"})
response = http.request(request)
puts response.to_s
Printing the response gives me #<Net::HTTPBadRequest:0x007fe37cac2da0> so what am I doing wrong to build or execute the request?
You probably want to call response.body
You can find the documentation for Net::HTTPResponse here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With