获取面对的问题这是我想在红宝石转换卷曲要求:与网:: HTTP在Ruby中
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代码。我在这里做错了什么?
我认为这是错误的'Net :: HTTP :: Get.new(url.request_uri)'。 'url.request_uri'返回'/ executor'。我想你需要传递整个url对象 – PericlesTheo 2014-09-28 18:03:43
在这种情况下,我收到以下错误:NoMethodError:undefined method'empty?'对于# –
2014-09-28 18:08:52