How do I send a DELETE request using a ruby ​​gem?

I am communicating with an API that requires a DELETE request with a JSON body. This works in the console:

curl -XDELETE http://api.com/endpoint_path/rest_resource -d '{"items":[{"type":"type1","item_id":"item1"}]}'

It seems that most of the stones for making HTTP requests do not support DELETE request with body (I tried RestClient and Curb). Is there a way to do this using some sort of Ruby gem (preferably Curb) or Net :: HTTP?

+3


source to share


2 answers


Here's one way, HTTParty :



HTTParty.delete("http://api.com/endpoint_path/rest_resource", { 
  :body => '{"items":[{"type":"type1","item_id":"item1"}]}'
})

      

+5


source


it could be used. This is the ORM for the api. https://github.com/remiprev/her

Usage example:



RestResource.destroy_existing(id, body_params)

      

0


source







All Articles