使用Ruby 发送Restful Request (Patch)

这里以PATCH操作为例,给出发送Restful Request的方法。

require 'rest-client'
require 'json'

url = "http://127.0.0.1/api/version/sources/source_name"

update_params = {"key" => "value"}
response = RestClient::Request.execute(:method => :patch, :url => url, :timeout => 10,  :open_timeout => 10, :payload => update_params.to_json)

参考链接
GitHub: Ruby Rest-Client Package

你可能感兴趣的:(使用Ruby 发送Restful Request (Patch))