0

我正在尝试使用 ruby​​ 从 github 上的公共仓库获取标签的 API 请求。我有时会遇到错误,有时它会起作用。大多数时候它没有。

我得到的错误:

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
4

0 回答 0