尝试使用ruby HTTParty发送删除

时间:2016-01-12 17:42:22

标签: ruby json cloudflare httparty

require 'httparty'
require 'json'
response = HTTParty.delete("https://api.cloudflare.com/client/v4/zones/5746746785687568678785/purge_cache",
            :headers => { "X-Auth-Email" => "myemail@company.com" , "X-Auth-Key" => "7456785476856789567965","Content-Type" => "application/json" } ,
            :body => {:"purge_everything" => "true"}.to_json
            )
puts response.body, response.message

我一直接受purge_everything必须设置为true作为回应。有什么想法吗?

1 个答案:

答案 0 :(得分:4)

您的Ruby代码看起来没问题,您只为true参数的"true"输错了错误。

根据Cloudflare's API docs,JSON应该看起来像purge_everything