Ruby中的Net::HTTP Get面临问题

Ruby中的Net::HTTP Get面临问题,ruby,net-http,Ruby,Net Http,这是我想在ruby中转换的curl请求: curl -k --get --data 'session.id=48d59b37-5875-4e49-8d79-6cf097d740f&ajax=executeFlow&project=test&flow=two' https://localhost:8443/executor 我应该这样回答: { "message" : "Execution submitted successfully with exec id 688

这是我想在ruby中转换的curl请求:

curl -k --get --data 'session.id=48d59b37-5875-4e49-8d79-6cf097d740f&ajax=executeFlow&project=test&flow=two' https://localhost:8443/executor
我应该这样回答:

{
  "message" : "Execution submitted successfully with exec id 688",
  "project" : "test",
  "flow" : "two",
  "execid" : 688
}
我将其转换为以下ruby代码:

require 'json'
require 'uri'
require 'net/http'

url = URI("https://localhost:8443/executor")
http = Net::HTTP.new(url.host, url.port)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = (url.scheme == 'https')
request = Net::HTTP::Get.new(url.request_uri)
request.set_form_data({'session.id' => '48d59b37-5875-4e49-8d79-6cf097d740f', 'ajax' => 'executeFlow', 'project' => 'test', 'flow' => 'two'}) 
response = http.request(request)
puts response
但这会抛出错误页面的html代码,而不是预期的响应。我在这里做错了什么?

这是来自文档,我没有测试它

url = URI("https://localhost:8443/executor")
request = Net::HTTP::Post.new(url)
request.set_form_data({'session.id' => '48d59b37-5875-4e49-8d79-6cf097d740f', 'ajax' => 'executeFlow', 'project' => 'test', 'flow' => 'two'}) 

response = Net::HTTP.start(url.hostname, url.port, use_ssl: url.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
  http.request(request)
end

我认为这是错误的
Net::HTTP::Get.new(url.request\u uri)
<代码>url.request_uri返回
/executor
。我认为您需要传递整个
url
object在这种情况下,我得到了以下错误:NoMethodError:undefined method'empty?#我得到了以下错误:
NoMethodError:undefined method empty?#
试试这个: