0

I'm trying an API request to get a tag from a public repo on github using ruby. I am getting an error at times and other times it works. Most of the time it does not.

Error I'm getting:

C:/Ruby25/lib/ruby/2.5.0/net/http.rb:939:in `rescue in block in connect': Failed to open TCP connection to https://api.github.com/repos/puppetlabs/puppetlabs-stdlib/tags:80 (no implicit conversion of URI::HTTPS into String) (TypeError)
puts "INFO: Checking #{pupmod} new releases".green
  require 'net/http'
  require 'json'
  require 'uri'
  url = "#{$github_pubapi}/#{pupmod}/tags"
  uri = URI.parse(url)
  headers = {
    'Authorization'=>'token df61c638274d9ca9e3ea663341f5af2bf122db08'
  }
  response = Net::HTTP.get(uri, headers)
  parsed = JSON.parse(response)
  latestRelease = parsed.first["name"]
  puts latestRelease
dsok
  • 1
  • This is weird. Are you sure that your network connection is stable ? Maybe it can be a good idea to try on an other network – Xero Jan 23 '19 at 20:22
  • Possible duplicate of [Using Net::HTTP.get for an https url](https://stackoverflow.com/questions/5786779/using-nethttp-get-for-an-https-url) – Max Jan 24 '19 at 15:02

0 Answers0