Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP METHOD categorization cancel vs. delete

Tags:

python

rest

http

In an API, what HTTP METHOD should be used for a cancel operation.

I imagine this wouldn't be a DELETE request, because the resource is not being disposed of. In which case, should it be a POST or a PUT ? Here is some documentation, but I still am not clear on the distinction from this: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

like image 594
David542 Avatar asked Nov 23 '14 06:11

David542


People also ask

Is delete a valid HTTP method?

The primary or most commonly-used HTTP methods are POST, GET, PUT, PATCH, and DELETE. These methods correspond to create, read, update, and delete (or CRUD) operations, respectively.

Which HTTP method must you use to remove a specific resource?

The HTTP DELETE method removes a resource at a specific URL. The HTTP POST method is often used while creating a resource in a collection when the final resource URL is not known.

Which method is completely deleting in RESTful API?

In RESTful APIs resources are typically deleted using the HTTP DELETE method. The resource that should be deleted is identified by the request URI. DELETE is an idempotent HTTP operation.


1 Answers

This isn't a DELETE. Cancelling an operation is a state change and a state change means an update.

I would personally use a PUT because you normally know the URI of the resource you are updating.

Also see this post for more details: PUT vs POST in REST.

like image 57
Bogdan Avatar answered Sep 28 '22 11:09

Bogdan