Search code examples
rubyrestrest-client

DELETE method with a payload using Ruby Rest:Client?


While I don't think it is very restful to have to include a payload in a DELETE request. I ran into an instance where I am testing a service that requires a payload for DELETE. Might there be a way using Ruby's Rest Client to accomplish this? Unfortunately, I am having a hard time with this one.

@json_request = '{"user_id": 5, "meta_data": "foo"}'
resource = RestClient::Resource.new "http://www.foo.com/some/process"
@response_update = resource.delete(@json_request, :content_type => :json, :accept => :json)

Output: ArgumentError: wrong number of arguments (2 for 0..1)


Solution

  • Currently it's not possible with that gem. You can see a PL addressing that. Maybe you could fork it and pull those changes to your own fork of the rest-client gem.

    The pull request https://github.com/rest-client/rest-client/pull/98