Created
January 28, 2015 20:33
-
-
Save srikanthjeeva/ed95ad278c187024e5b7 to your computer and use it in GitHub Desktop.
https GET request with Basic Auth in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'net/https' | |
require 'uri' | |
uri = URI('https://example.com/rest/api/2/1') | |
Net::HTTP.start(uri.host, uri.port, | |
:use_ssl => uri.scheme == 'https', | |
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| | |
request = Net::HTTP::Get.new uri.request_uri | |
request.basic_auth 'username', 'password' | |
response = http.request request # Net::HTTPResponse object | |
puts response | |
puts response.body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment