ruby调用REST模式API测试方法
ruby调用REST方式API测试方法
也可以用另外一种方式用curl命令快速调试api接口。
require 'httparty' require 'json' response = HTTParty.post(url, { :body => http_body.to_json, :headers =>{"Content-Type"=>"application/json", :debug_output=> $stderr }) def http_body result={} result["a"]="A" result["b"]="B" return result end 其中 :debug_output=> $stderr为打印post请求内容。
也可以用另外一种方式用curl命令快速调试api接口。
curl -H "Content-Type: application/json" -d "{\"a\":\"A\",\"b\":\"B\"}" “your api url” -X POST