0

I’m new to NET HTTP and Ruby on Rails and I want to use some Get Request to take some data from a website. There isn’t much help on this topic online. Is it possible if someone guide me in the right direction.

Other info :

The website I’m calling to : https://exampledomain.com/getinfo

Uses basic auth

Requires Content type to be application/Jason

Has 2 params: Page Page_size

If someone could point me to some documentation or better yet give me a solution that would be great

I have searched through most websites and only found get request with basic auth and get request with params but never together

1 Answers1

0
 uri = URI('https://exampledomain.com/getinfo/')
 http = Net::HTTP.new(uri.host, uri.port)
 http.use_ssl = true
 request = Net::HTTP::Get.new(uri.path, 'Content Type' => 'application/json')
 request.basic_auth('username', 'pass')
 resp = http.request(request)
 resp.body'