make a http put request in ruby

http, uri and net/http are the required libraries

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

uri = URI.parse("https://example.com/api/resource/123") request = Net::HTTP::Put.new(uri) request.content_type = "application/json" request.body = JSON.dump({"key" => "value"})

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request) end

puts response.code # print the response code puts response.body # print the response body

main.rb
0 chars
1 lines

related categories

gistlibby LogSnag