0

I need to add a body on default destroy method, as a follow: DELETE /path/{id}, body: {}

Googling around, I couldn't find an answer that came close to the solution I need. Has anyone done something similar?

According to the jsonapi standard documentation, this conforms to the spec: https://jsonapi.org/format/.

"Note: RFC 7231 specifies that a DELETE request may include a body, but that a server may reject the request. This spec defines the semantics of a server, and we are defining its semantics for JSON:API."

def destroy(params = {})      
    self.class.connection.delete(self.class.path + "/#{id}", body: params.to_json)
 end
3
  • Important point: I'm using the json_api_client gem for that. Commented Feb 7, 2023 at 15:31
  • What is self.class.connection? We need a few more details here or we will be unable to assist. Commented Feb 9, 2023 at 21:59
  • Updating: After further research, I decided against this approach, as in the source code for the 'json_api_client' gem, any body in get or delete requests is disregarded. To go that way, I would have to proceed with overriding the code, which wouldn't sound good with the patterns. Thanks @engineersmnky. Commented Feb 16, 2023 at 0:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.