2

您能否纠正我在调用 http delete 时在这里犯的错误。我得到 InternalServerError 没有进一步的解释。

相同的调用在 FireFox RESTClient 插件上运行良好。

示例 RestClient

require "rest_client"
data= {"name" => "foo"}
res = RestClient.delete(url, data.to_json)

抛出:/lib/restclient/request.rb:72:in process_url_params': undefined methoddelete_if' for # (NoMethodError)

样本网/http

http = Net::HTTP.new('some ip valid', port)
headers = {'Content-Type' => 'application/json'}
data = {"name" => "foo"}
resp, data = http.delete(path, headers)

抛出:Net::HTTP InternalserverError

4

1 回答 1

0

我遇到了这个问题,并通过删除 json 数据部分使其工作。

def doRestDelete(url, values)
    puts "URL: ",  url
    jsonValues = values.to_json
    puts jsonValues
    begin
        raw = RestClient.delete url # removed this bit --->  , jsonValues
        puts raw
    rescue => e
        abort(e.response)
    end
    return JSON.parse(raw)
end     
于 2015-01-02T01:08:14.890 回答