Programming-Idioms

History of Idiom 183 > diff from v4 to v5

Edit summary for version 5 :
New Ruby implementation by user [robzombie111]

Version 4

Version 5

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Imports
require 'net/http'
Code
port = 1234
path = '/update_endpoint.json'
body = 'optional body content'
header = 'optional header'

http = Net::HTTP.new('www.exampledomain.com', port, header)
response = http.send_request('PUT', 'path', body)
Comments bubble
If port is not given, the default port for http(s) is used.
Body and headers are optional.
Doc URL
https://ruby-doc.org/stdlib-2.6.4/libdoc/net/http/rdoc/index.html