Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save srikanthjeeva/ed95ad278c187024e5b7 to your computer and use it in GitHub Desktop.
Save srikanthjeeva/ed95ad278c187024e5b7 to your computer and use it in GitHub Desktop.
https GET request with Basic Auth in Ruby
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