Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Create, read, update and delete
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== RESTful APIs === The acronym CRUD also appears in the discussion of [[Representational state transfer|RESTful APIs]]. Each letter in the acronym may be mapped to a [[HTTP method|Hypertext Transfer Protocol (HTTP) method]]: {| class="wikitable" |- ! CRUD ! HTTP |- | Create | [[Hypertext Transfer Protocol#Request methods|POST, PUT]] if we don't have `id` or `uuid`<!-- Do not replace with POST which is not a CRUD operation (cf. below). --> |- <!-- POST should be added. POST is a CRUD operation in the same way as SQL INSERT. If the key is specified in INSERT, then the equivalent REST is indeed PUT. On the other hand, if a table autogenerates the key and the INSERT doesn't have the key, then the equivalent REST is POST. "that doesn’t mean we can live without it. POST serves many useful purposes in HTTP." It is the standard way of creating a new object where the server assigns the id. We can't help that in all other ways, POST is as loosy goosy as Roy said. The user agent doesn't always have the onus of knowing the key/id when creating in web or relational databases. Knowing the key when creating is NOT a requirement of CRUD, SQL, or REST. --> | Read | [[Hypertext Transfer Protocol#Request methods|GET]] |- | Update | [[Hypertext Transfer Protocol#Request methods|PUT]] to replace, [[Hypertext Transfer Protocol#Request methods|PATCH]] to modify |- | Delete | [[Hypertext Transfer Protocol#Request methods|DELETE]] |} In HTTP, the GET (read), PUT (create and update), POST (create - if we don't have `id` or `uuid`), and DELETE (delete) methods are CRUD operations as they have storage management semantics, meaning that they let [[user agent]]s directly manipulate the states of target [[Web resource|resources]].<ref>{{cite web |url=https://tools.ietf.org/html/rfc7231#section-4 |title=Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content, Section 4 |last=Fielding |first=Roy |date=June 2014 |website=IETF |publisher=Internet Engineering Task Force (IETF) |access-date=2018-02-14 |rfc=7231}}</ref> The [[Hypertext Transfer Protocol#Request methods|POST]] method, on the other hand, is a process operation that has target-resource-specific semantics which typically exceed the scope of CRUD operations.<ref name="it-is-okay-to-use-post">{{cite web|url=https://roy.gbiv.com/untangled/2009/it-is-okay-to-use-post |title=It is okay to use POST |author=Roy T. Fielding |publisher=roy.gbiv.com |date=2009-03-20 |access-date=2020-04-14 |quote=POST only becomes an issue when it is used in a situation for which some other method is ideally suited: e.g., retrieval of information that should be a representation of some resource (GET), complete replacement of a representation (PUT), or any of the other standardized methods that tell intermediaries something more valuable than “this may change something.” The other methods are more valuable to intermediaries because they say something about how failures can be automatically handled and how intermediate caches can optimize their behavior. POST does not have those characteristics, but that doesn’t mean we can live without it. POST serves many useful purposes in HTTP, including the general purpose of “this action isn’t worth standardizing.”}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)