* RubyでHTTPリクエスト送信 [#s7bbc159] #mycode2(){{ require 'net/http' require 'net/https' require 'json' URL = 'https://xxx.xxx.xxx/xxx/' data = { "var1"=> "ABCDEFG", "var2"=> "HIJKLMN" } url = URI.parse(URL) http = Net::HTTP.new(url.host, url.port) if URL.match("https:") http.use_ssl = true #http.verify_mode = OpenSSL::SSL::VERIFY_NONE end req = Net::HTTP::Get.new(url.path) #req = Net::HTTP::Post.new(url.path) #req = Net::HTTP::Get.new(url.path) req = Net::HTTP::Post.new(url.path) #req = Net::HTTP::Put.new(url.path) #req = Net::HTTP::Delete.new(url.path) req["Content-Type"] = "application/json" req.body = data.to_json res = http.request(req) puts res.code puts res.body }}